注
意
:
\color{red}注意:
注意:
1.全部转换为小写字母
2.只需要统计英文字母的字符
3.注意出现次数相同时,需要输出ASCII码小的那个
#include <iostream>
#include <string>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main(){
string str;
getline(cin, str);
transform(str.begin(), str.end(),str.begin(),::tolower);
unordered_map<char, int> mp;
int Max = 0;
char ch;
for(auto c: str) {
if(isalpha(c)){
mp[c]++;
if(mp[c] > Max){
Max = mp[c];
ch = c;
}else if(mp[c] == Max && c < ch) ch = c;
}
}
cout<<ch<<" "<<Max<<endl;
return 0;
}