题目链接:点击打开链接
知识点笔记:
AC代码:
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
char str[1010];
gets(str);
int hashTable[256];
memset(hashTable,0,sizeof(hashTable));
int len=strlen(str);
for(int i=0;i<len;i++){
char c=str[i];
if(str[i]>='a'&&str[i]<='z')
{
hashTable[c]++;
}else if(str[i]>='A'&&str[i]<='Z'){
c+=32;
hashTable[c]++;
}
}
int max=-1,index=0;
for(int i=0;i<256;i++){
if(max<hashTable[i]){
max=hashTable[i];
index=i;
}
}
printf("%c %d",index,max);
return 0;
}