#include<stdio.h> #include<ctype.h> #include<string.h> char s[10000]; int cnt[26]; int main(int argc, char *argv[]) { while(gets(s)!=NULL) { memset(cnt,0,sizeof(cnt)); for(int i=0;i<strlen(s);++i) { if(isalpha(s[i])&&isupper(s[i])) { cnt[s[i]-'A']++; } } for(int i=0;i<26;++i) { printf("%c:%d\n",i+'A',cnt[i]); } } return 0; } /************************************************************** Problem: 1098 User: kirchhoff Language: C Result: Accepted Time:10 ms Memory:924 kb ****************************************************************/
原文地址:http://blog.csdn.net/wdkirchhoff/article/details/42218167