0
我試圖插入一個元素到這個二維矢量可變的,但我不知道怎麼做,這種奇怪的矢量型插入元素爲2D向量C++
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
}
}
}
我要插入的地方是通過註釋來指定的。我希望我的價值進入對和披值的整數部分爲雙部分