计量大学 F Flag Scramble Competition

F Flag Scramble Competition

The party began, the greasy uncle was playing cards, the fat otaku was eating, and the little beauty was drawing.

At the party, people will play a game called Flag Scramble. The rule of this game is that the host speaks a sentence, and people find the letter that appears the most in the sentence. The first person who calls this letter wins. If your answer is wrong or someone else wins, you will be fined. You don’t need to deal with many situations, just find the letter that appears most frequently in the statement of this problem and print it out, the letters are case insensitive.

Very simple, right? Please remember to count carefully! Do not count wrong! This is the most straightforward question after all, but do not get a time penalty here, it is not worth it! In order for everyone to have a good experience, I really tried my best, and finally thought of such a question as a sign-in question, do not thank me too much, manual dog head.

Input Specification:

There is no input for this question, please output your answer directly!

Output Specification:

Just print a lower-case letter, indicating your answer.

Sample Input:

(no sample input)

Sample Output:

(no sample output)

题意

需要统计出题目中出现次数最多的字母,没有输入!

参考代码

#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int c[N];
int main() {
	string s;
	//cin >> s;
	s = "At the party, people will play a game called Flag Scramble. The rule of this game is that the host speaks a sentence, and people find the letter that appears the most in the sentence. The first person who calls this letter wins. If your answer is wrong or someone else wins, you will be fined. You don't need to deal with many situations, just find the letter that appears most frequently in the statement of this problem and print it out, the letters are case insensitive.\n"
		"Very simple, right ? Please remember to count carefully!Do not count wrong!This is the most straightforward question after all, but do not get a time penalty here, it is not worth it!In order for everyone to have a good experience, I really tried my best, and finally thought of such a question as a sign - in question, do not thank me too much, manual dog head.";
	//cout << s << endl;
	for (auto &x : s) {
		if (x >= 'a' && x <= 'z') {
			c[x - 'a']++;
		}
		else if(x >='A' && x <='Z') {
			c[x - 'A']++;
		}
	}
	int pos = 'a';
	for (int i = 0; i < 26; i++) {
		if (c[i] > c[pos]) pos = i;
	}
	cout << (char)(pos + 'a') << endl;
	return 0;
}

Tips

现场赛似乎WA三发。。。开始没看懂题意。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值