http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1525
#include <stdio.h>
#include <string.h>
int small[26],big[26];//ASCII小的字母出现次数,ASCII大的字母出现次数
int main()
{
char str[105];
int i,max1,max2;
while(gets(str)!=NULL)
{
memset(small,0,sizeof(small));
memset(big,0,sizeof(big));
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='A'&&str[i]<='Z')
small[str[i]-'A']++;
if(str[i]>='a'&&str[i]<='z')
big[str[i]-'a']++;
}
max1=0;//出现次数最多的(大写)字母的下标
for(i=1;i<26;i++)
if(small[i]>small[max1])
max1=i;
max2=0;//出现次数最多的(小写)字母的下标
for(i=1;i<26;i++)
if(big[i]>big[max2])
max2=i;
if(small[max1]>=big[max2])
printf("%c %d\n",max1+65,small[max1]);
else
printf("%c %d\n",max2+97,big[max2]);
}
return 0;
}
/**************************************
Problem id : SDUT OJ 1525
User name : 2333
Result : Accepted
Take Memory : 244K
Take Time : 0MS
Submit Time : 2016-07-17 20:54:19
**************************************/