poj 1298 The Hardest Problem Ever
来源:互联网 发布:小学生学编程视频教程 编辑:程序博客网 时间:2024/04/20 10:19
//第一次竟然因为map的映射中写错了一个而WA了一次,哎,粗心! #include "iostream"#include "string"#include "map"#include "cctype"using namespace std;map<char, char> m;int main(){ 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'; string input, ans; int len, i; while (1) { getline(cin, input); if (input == "START" || input == "END") continue; if (input == "ENDOFINPUT") break; ans.clear(); len = input.length(); for (i = 0; i < len; i++) { if (isalpha(input[i])) ans.push_back(m[input[i]]); else ans.push_back(input[i]); } cout << ans << endl; } system("pause");}