字母统计 题解:
#include <stdio.h>
#include <string.h>
int main() {
int count[26] = { 0 };
static char c[100];
gets(c);
for (int i = 0;c[i] != '\0';i++) {
if (c[i] >= 'A' && c[i] <= 'Z') {
count[c[i] - 'A']++;
}
}
for (int i = 0;i <= 25;i++) {
printf("%c:%d\n",'A'+i,count[i]);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发