hud 1860 简单字符串处理

来源:互联网 发布:淘宝hsf框架 编辑:程序博客网 时间:2024/05/01 15:13

#include<iostream>
#include<string>
using namespace std;
int main()
{
    char a[6],b[82];
   
    int x,y;
    while(gets(a)){
           int c[82]={0};
           if(!strcmp(a,"#")) break;//或者if(a[0]=='#')break;开始我就犯了超低级的错误写成if(a=='#')a是数组啦~~
           x=strlen(a);
           gets(b);
           y=strlen(b);
           for(int i=0;i<y;i++)
             for(int j=0;j<x;j++){
                     if(b[i]==a[j])
                     c[j]++;
                     }
           for(int j=0;j<x;j++)
           cout<<a[j]<<' '<<c[j]<<endl;
           }
         //  system("pause");
           return 0;
           }