I THIS IS A TEST i ng this is a long test string #
I 2 i 3 5 n 2 g 2
解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7745-1-1.html
#include <iostream> #include <cstring> using namespace std; int main() { char a[6],b[81]; int i,j,count[5]; cin.getline(a,6); while(a[0]!='#') { cin.getline(b,81); for(i=0;i<5;i++) count[i]=0; for(i=0;i<strlen(a);i++) { for(j=0;j<strlen(b);j++) { if(a[i]==b[j]) { count[i]++; } } } for(i=0;i<strlen(a);i++) { cout<<a[i]<<" "<<count[i]<<endl; } cin.getline(a,6); } return 0; } /************************************************************** Problem: 1021 User: vhreal Language: C++ Result: Accepted Time:0 ms Memory:1520 kb ****************************************************************/
原文地址:http://blog.csdn.net/wtyvhreal/article/details/42212163