题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/4ec4325634634193a7cd6798037697a8
#include <iostream> #include <string> #include <cstdio> using namespace std; int main() { string a, b; while (getline(cin, a)) { if ("#" == a) { break; } getline(cin, b); for (char & i : a) { int k=0; for (char j : b) { if (i == j) { ++k; } } cout << i << " " << k << endl; } } }