我正在尝试将一个元素插入到这个 2D 矢量变量中,但我不确定如何使用这种奇怪的矢量类型来做到这一点
void CaesarCypher::caesarAttack(string inputFileName, string frequencyFileName, string outputFileName, string phiFile)
{
vector<pair<char, double>> cipherTable = charFreqGen(inputFileName, outputFileName, numberDisplayed);
vector<pair<char, double>> frequencyTable = charFreqGen(frequencyFileName, outputFileName, 150);
vector<pair<int, double>> phiTable;
for (int i = 0; i <= 94; i++)
{
double phi = 0.0;
for (const auto& p : cipherTable)
{
char key = (char) ((int) p.first - i);
auto find_it = find(frequencyTable.begin(), frequencyTable.end(), [key](const pair<char, double>& x) { return x.first == key; });
double value;
if (find_it != frequencyTable.end())
{
value = find_it->second;
}
phi += p.second * value;
//Insert a new element into the phiTable with the int parameter being i and the double paramter being phi
}
}
}
我要插入的位置是用注释指定的。我希望 i 值进入该对的整数部分,而 phi 值进入双精度部分