#include <iostream>
#include <string>
#include <map>
#include <cctype>
using namespace std;
map<char, char> m;
int main()
{
int i, len;
string str, ans;
ans.clear();
m['A'] = 'V', m['B'] = 'W', m['C'] = 'X', m['D'] = 'Y', m['E'] = 'Z',
m['F'] = 'A', m['G'] = 'B', m['H'] = 'C', m['I'] = 'D', m['J'] = 'E',
m['K'] = 'F', m['L'] = 'G', m['M'] = 'H', m['N'] = 'I', m['O'] = 'J',
m['P'] = 'K', m['Q'] = 'L', m['R'] = 'M', m['S'] = 'N', m['T'] = 'O',
m['U'] = 'P', m['V'] = 'Q', m['W'] = 'R', m['X'] = 'S', m['Y'] = 'T', m['Z'] = 'U';
while (getline(cin, str)){
if (str == "ENDOFINPUT") break;
else if (str == "START") continue;
else if (str == "END"){
cout << ans << endl;
ans.clear();
}
else{
len = str.length();
for (i = 0; i < len; i++){
if (isalpha(str[i]))
ans.push_back(m[str[i]]);
else
ans += str[i];
}
}
}
system("pause");
}
poj 3749 破译密码
最新推荐文章于 2022-02-25 21:57:21 发布
这是一个使用C++编写的程序,旨在破译一种特定的字母替换密码。程序通过建立映射表将英文大写字母按特定规律替换,读取输入的字符串,遇到'ENDOFINPUT'结束输入,'START'则跳过,其他字符串则根据映射表转换并输出解密后的文本。程序最后调用'system("pause")'暂停程序运行,以便查看结果。
摘要由CSDN通过智能技术生成