HDOJ题目地址:传送门
I THIS IS A TEST i ng this is a long test string #
I 2 i 3 5 n 2 g 2 注:第2个测试用例中,空格也是被统计的字符之一。
#include<stdio.h>
#include<string.h>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
string s,str;
while(1){
int result=0;
getline(cin,s);
if(s=="#")
break;
getline(cin,str);
for(int i=0;i<s.size();i++){
for(int j=0;j<str.size();j++){
if(s[i]==str[j]){
result++;
}
}
printf("%c %d\n",s[i],result);
result=0;
}
}
}
ACM--字母个数--HDOJ 1860--统计字符--字符串
原文:http://blog.csdn.net/qq_26891045/article/details/52064612