题解 | #字母统计#
字母统计
http://www.nowcoder.com/practice/de7bf0945c1c4bd1aa9d49573b831f3c
#include<iostream> #include<cstdio> #include<string> #include<cstring> using namespace std; int main() { string str; int num[128]= {0}; while(cin>>str) { memset(num,0,sizeof(num)); for(int i=0; i<str.size(); i++) { num[str[i]-'A']++; } for(int i=0; i<26; i++) { printf("%c:%d\n",i+'A',num[i]); } } return 0; }