AcWing 3615. 单词个数统计
原题链接
简单
作者:
故事里的大魔王
,
2025-01-11 18:11:56
,
所有人可见
,
阅读 1
#include <iostream>
#include <string>
#include <set>
using namespace std;
int appear[26];
int main(){
// A : 65 a: 97
int wordNum = 0;
int alNum = 0;
int max = 0x80000000;
string str;
while(cin >> str){
++ wordNum;
alNum += str.size();
for(int i = 0; i < str.size(); ++ i)
if(str[i] < 97) ++ appear[str[i] - 'A'];
else ++ appear[str[i] - 'a'];
}
for(int i = 0; i < 26; ++ i)
if(max < appear[i])
max = appear[i];
cout << alNum << endl;
cout << wordNum << endl;
for(int i = 0; i < 26; ++ i)
if(max == appear[i])
printf("%c ", i + 'a');
cout << endl;
cout << max << endl;
return 0;
}