POJ水题 1298
#include "stdafx.h" #include <iostream> #include <string> using namespace std; int main() { string tol,result; while(getline(cin,tol)) { unsigned i=0; if(tol=="START") continue; else if(tol=="END") cout<<result<<endl; else if(tol=="ENDOFINPUT") break; else { while(i<tol.size()) { if(tol[i]<70 &&tol[i]>=65)//A-E tol[i]= tol[i]+21 ; else if(tol[i]>=70&&tol[i]<=90)//F-Z tol[i]= tol[i]-5 ; i++; } result=tol; } } return 0; }
可用map映射字母一一对应来替换,此处我就直接替换了,只是不方便扩展