我已经生成了一个随机文本文件
A B C D E F G H
T W G X Z R L N
我想对我的消息进行编码,以便 A = T 、 B = W 、 C = G 等等..
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int
main ()
{
string getmsg;
ifstream openfile ("random.txt");
if (openfile.is_open ()) {
while (! openfile.eof ()) {
getline (openfile,getmsg); //read from random.txt
cout << getmsg << endl;
}
}
}
我很卡在这里。
例如。当我输入单词“HAD”时,它将显示“NTX”,通过使用相同的随机文本文件,我可以输入“NTX”并返回“HAD”