水题,不解释。 // The Hardest Problem Ever.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #include<fstream> #include<string> #include<vector> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { ifstream cin("d://1.txt"); string cipher="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string plain="VWXYZABCDEFGHIJKLMNOPQRSTU"; string s; int i,j; while(cin>>s){ if(s=="ENDOFINPUT")break; if(s=="START"){ getline(cin,s); getline(cin,s); for(i=0;i!=s.size();i++) for(j=0;j!=cipher.size();j++){ if(s[i]==' ')i++; else{ if(s[i]==cipher[j]) {s[i]=plain[j];break;} } } cout<<s<<endl; } if(s=="END") continue; } system("pause"); return 0; }