题解 | #字母统计#
字母统计
https://www.nowcoder.com/practice/de7bf0945c1c4bd1aa9d49573b831f3c
#include <iostream> using namespace std; int main() { string str; int count; while (getline(cin, str)) { for (int j = 'A'; j <= 'Z'; j++) { count = 0; for (int i = 0; i < str.size(); i++) { if ((int)str[i] == j) count++; } printf("%c:%d\n", (char)j, count); } } }