没有算法。
关键:scanf接收字符串不能带空格。用gets
char*字符串,strcmp才能比较比较
#include<iostream>
#include<stdio.h>
using namespace std;
char a[6];
char b[81];
int main()
{
char cmpa,cmpb;
int result;
while(1)
{
if(gets(a) == NULL || strcmp(a,"#") == 0)
break;
if(gets(b) == NULL || strcmp(b,"#") == 0)
break;
for(int i =0;i<6;++i)
{
char cmpa = a[i];
if(cmpa == '\0')
break;
else
{
result = 0;
for(int j =0;j<81;++j)
{
char cmpb = b[j];
if(cmpb == '\0')
break;
else
{
if(cmpa == cmpb)
++result;
}
}
printf("%c %d\n",cmpa,result);
}
}
}
return 0;
}