听灌多
  • 板块灌水区
  • 楼主yexuanqi
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/9/27 21:53
  • 上次更新2024/9/28 08:20:29
查看原帖
听灌多
1217860
yexuanqi楼主2024/9/27 21:53

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;
}
2024/9/27 21:53
加载中...