输入:
不超过500个字符的英文,含大小写英字母、空格、引号、标点符号等。
输出:
最多26行,每行第一项为小写字母,第二项为对应字母的个数,字母与个数之间用空格隔开,字母个数为0的不输出。
样例输入:
aaaaaccccc@
样例输出:
a 5
c 5
输入:
不超过500个字符的英文,含大小写英字母、空格、引号、标点符号等。
输出:
最多26行,每行第一项为小写字母,第二项为对应字母的个数,字母与个数之间用空格隔开,字母个数为0的不输出。
样例输入:
aaaaaccccc@
样例输出:
a 5
c 5
#include<stdio.h>
int main()
{
char str[500];
int num[26] = { 0 };
scanf("%s",&str);
int i = 0;
while (str[i]!='@')
{
num[str[i] - 'a']++;
i++;
}
for (int i = 0; i < 26; i++)
{
if (num[i]!=0)
{
printf("%c %d",'a'+i,num[i]);
printf("\n");
}
}
return 0;
}