题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/4ec4325634634193a7cd6798037697a8
#include <iostream> using namespace std; #include<string> int main() { string str1,str2; while(getline(cin,str1)){ if(str1=="#") break; getline(cin,str2); for(int i=0;i<str1.size();i++){int count=0; for(int j=0;j<str2.size();j++){ if(str1[i]==str2[j]){count++;} } cout<<str1[i]<<" "<<count<<endl; } } } // 64 位输出请用 printf("%lld")