Notice
Hash散列
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
int a[40] = {0}; //保存36个小写字母的个数
string s;
getline(cin,s); //字符串有空格,不能直接用cin
char c;
for(int i = 0;i < s.length();i++){ //找出字母并存入
if(isalpha(s[i])){
c = tolower(s[i]);
a[c - 'a']++;
}
}
//寻找个数最多的
int pos = 0,max = a[0];
for(int i = 1;i < 26;i++){
if(max < a[i]){
max = a[i];
pos = i;
}
}
//输出
cout << char('a' + pos) << " " << a[pos];
//printf("%c %d", t + 'a', max);
return 0;
}