admin管理员组文章数量:1530021
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三发。。。开始没看懂题意。
本文标签: 大学FlagcompetitionScramble
版权声明:本文标题:计量大学 F Flag Scramble Competition 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1726693457a1080928.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论