Description
英文字母里出现频率最高的是哪个字母呢? 给定一个字符串,输出字符串中出现次数最多的字母。
Input
输入一个只含有大小写字母和空格的字符串,长度不超过100,以回车结束。
Output
输出一个小写字母,表示该字符串中出现次数最多的字母。若答案有多个,则只输出ASCII码最小的那个。
Sample Input
An apple
Sample Output
a
HINT
Source
char ch[150];
int a[150]= {0};
int x,i=0,j;
int max;
while((ch[i]=getchar())!='\n')
{
if(ch[i]>='A'&&ch[i]<='Z')
ch[i]+=32;
x=ch[i];
a[x]++;
i++;
}
max=a[122];
for(i=122; i>=97; i--)
if(a[i]>=max)
{
max=a[i];
j=i;
}
printf("%c",j);
return 0;