20pts,P1906,求条
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N];
int main()
{
string s, text, e;
int t, maxv;
bool flag = 1;
cin >> s, getline(cin, text), getline(cin, text), cin >> e;
memset(a, 0, sizeof a);
maxv = -1;
for(int i = 0; i < text.size(); i ++)
{
if(text[i] >= 'a') text[i] -= 32;
++ a[text[i]];
}
for(int i = 'A'; i <= 'Z'; i ++)
if(a[i] >= maxv)
maxv = a[i], t = 'E' - i;
for(int i = 0; i < text.size(); i ++)
if(text[i] >= 'A' && text[i] <= 'Z')
{
text[i] += t;
if(text[i] > 'Z') text[i] -= 26;
if(text[i] < 'A') text[i] += 26;
}
cout << text << endl;
while(cin >> s, getline(cin, text), getline(cin, text), cin >> e)
{
if(s == "ENDOFINPUT") break;
for(int i = 0; i < text.size(); i ++)
if(text[i] >= 'A' && text[i] <= 'Z')
{
text[i] += t;
if(text[i] > 'Z') text[i] -= 26;
if(text[i] < 'A') text[i] += 26;
}
cout << text << endl;
}
return 0;
}