1042 字符统计 (20 分)

#include<stdio.h>

#include<string.h>

int main()

{

char str[1010];

int word[25]={0,};

int j=0;

gets(str);

int l=strlen(str);

int i;

for(i=0;i<l;i++)

扫描二维码关注公众号,回复: 6188218 查看本文章

{

if((str[i]<='Z'&&str[i]>='A')||(str[i]<='z'&&str[i]>='a'))

{

if(str[i]<='Z'&&str[i]>='A')

         word[str[i]-'A'+1]++;

else

         word[str[i]-'a'+1]++;

}

}

int temp=0;

for(i=1;i<=24;i++)

if(temp<word[i])

temp=word[i];

for(i=1;i<=24;i++)

{

if(temp==word[i])

     {

         printf("%c ",i+'a'-1);

         break;

     }

}

printf("%d",temp);

return 0;

}

猜你喜欢

转载自blog.csdn.net/yubai258/article/details/90045898