/* * POJ_3749.cpp * * Created on: 2013年11月26日 * Author: Administrator */ #include <iostream> #include <cstdio> #include <string> using namespace std; char m[500];//也可以用map来做.. 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 str; string ans; while(getline(cin,str)){//***这是C++种的读取一行的写法... if(str == "START"){ continue; }else if(str == "END"){ cout << ans <<endl; ans.clear(); }else if(str == "ENDOFINPUT"){ break; }else{ int len = str.length(); int i; for(i = 0 ; i < len ; ++i){ if(isalpha(str[i])){ // ans += m[str[i]]; ans.push_back(m[str[i]]);//建议用这种写法,上面的写法有警告... }else{ ans += str[i]; } } } } return 0; }