#include<stdio.h> #include<string.h> char s1[10]; char s2[100]; int main(int argc, char *argv[]) { while(gets(s1)&&s1[0]!='#') { gets(s2); for(int i=0;i<strlen(s1);++i){ int count=0; for(int j=0;j<strlen(s2);++j) { if(s2[j]==s1[i]) count++; } printf("%c %d\n",s1[i],count); } } return 0; } /************************************************************** Problem: 1021 User: kirchhoff Language: C Result: Accepted Time:0 ms Memory:912 kb ****************************************************************/
原文:http://blog.csdn.net/wdkirchhoff/article/details/42212789