文章
145
粉丝
217
获赞
21
访问
81.9k
#include <stdio.h>
#include <string.h>
int JudgeC(char c)
{
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return 1;
else if(c == ' ') return 0;
else if(c == '\n') return -1;
}
int main()
{
char c;
int Zimu = 0,Word = 0,a[26] = {0},flag = 0,count = 0;
while(c = getchar())
{
if(JudgeC(c) == 1)
Zimu++,flag = 1,count++;
else if(JudgeC(c) == 0)
flag = 0;
else if(JudgeC(c) == -1)
if(flag == 1 || count != 0)
{
Word++;
break;
}
if(!flag && count != 0) Word++,count = 0;
if(flag)
if(c >= 'a' && c<= 'z')
a[c-'a'-0]++;
else a[c-'A'-0]++;
}
int max = 0,i;
for(i = 1; i < 26; i++)
if(a[max] < a[i])
max = i;
printf("%d\n%d\n",Zimu,Word);
for(i = 0; i < 26; i++)
if(a[max] == a[i])
printf("%c ",'a'+i);
printf("\n%d\n",a[max]);
return 0;
}
登录后发布评论
暂无评论,来抢沙发