#include <iostream> #include <cstdio> #include <string> #include <algorithm> using namespace std; /** * 字母统计--上海交通大学 * @return */ int main() { string str; while (getline(cin, str)) { int count[128] = {0}; /* * 统计str字符串中每个字符出现的次数 * 以字符的ASCII为count[]数组的索引 */ for (int i = 0; i < str.size(); ++i) { count[str[i]]++; } /* * 输出大写字符A~Z出现的次数 */ for (char j = 'A'; j <= 'Z'; ++j) { cout << j << ":" << count[j] << endl; } } return 0; }