Description
We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.
Input
Input consists of up to 100,005 dictionary entries, followed by a blank line, followed by a message of up to 100,005 words. Each dictionary entry is a line containing an English word, followed by a space and a FatMouse word. No FatMouse word appears more than once in the dictionary. The message is a sequence of words in the language of FatMouse, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
Output is the message translated to English, one word per line. FatMouse words not in the dictionary should be translated as "eh".
Sample Input
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
atcay
ittenkay
oopslay
Sample Output
cat
eh
loops
题解:查找后缀相同的输出,没有则输出eh。
代码如下:
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
struct pin
{
char f[15];
char s[15];
};
int main()
{
struct pin a[100];
int i=0,j,k,m;
char b[100];
while(gets(b))
{
if(b[0]==0)
break;
sscanf(b,"%s%s",a[i].f,a[i].s);
i++;
}
while(~scanf("%s",b))
{
k=0;
for(j=0; j<i; j++)
if(strcmp(a[j].s,b)==0)
{
k++;
m=j;
}
if(k>0)
printf("%s\n",a[m].f);
else
printf("eh\n");
}
return 0;
}