解题说明:此题是一道字符串判断题,进行字符串匹配后输出即可。
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
int n, m, i, j, l;
scanf("%d %d\n", &n, &m);
char a[2005][225], b[2005][225], c[2005][225];
for (i = 0; i<n + m; i++)
{
scanf("%s", a[i]);
scanf("%s", b[i]);
}
for (i = 0; i<n; i++)
{
l = 0;
strcpy(c[i], b[i]);
l = strlen(c[i]);
c[i][l] = ';';
}
for (i = n; i<m + n; i++)
{
for (j = 0; j<n; j++)
{
if (strcmp(b[i], c[j]) == 0)
{
printf("%s %s #%s", a[i], b[i], a[j]);
break;
}
}
printf("\n");
}
}