#include<bits/stdc++.h> #include <unordered_map> using namespace std; //统计字符串中指定字符出现的次数 int count(char c, string str2) { int sum = 0; for (char s : str2) { if (s == c) { sum++; } } return sum; } int main() { string str1, str2; while (getline(cin, str1)) { //str1为"#"时循环结束 if (str1 == "#") { break; } else { getline(cin, str2); //遍历字符串1,统计字符串2中某字符出现的次数并输出 for (char c :str1) { cout << c << " " << count(c, str2) << endl; } } } }