码迷,mamicode.com
首页 > 其他好文 > 详细

【输入回车结束输入】Language of FatMouse

时间:2015-04-15 11:08:48      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

Language of FatMouse

时间限制: 1 Sec  内存限制: 64 MB 提交: 86  解决: 54 [提交][ 状态 ][ 讨论版]

题目描述

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 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 is the message translated to English, one word per line. FatMouse words not in the dictionary should be translated as "eh".

样例输入

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

样例输出

cat
eh
loops

主要是结束字典输入的问题,所以用gets();当输入为回车时,长度为0,结束输入;
输入Fatmouse时记得从gets()里复制过来,输出时记得英语输出要遇到空格结束,
因为输入时把英语和Fatmouse都记录在英语里了(记住输入F语时用EOF,挂了一次)

#include <stdio.h>
#include <string.h>
struct Dictouy
{
    char china[22],cat[12];
}s[100019];
int main()
{
    char a[12];
    int i,j,k,temp,t,p,len;
    for(i=0;i<100019;i++)
    {
        gets(s[i].china);len=strlen(s[i].china);
        if(len==0)
            break;
        t=0;
        for(k=0;k<len;k++)
            if(s[i].china[k]== )
            {
                for(j=k+1;j<len;j++)
                    s[i].cat[t++]=s[i].china[j];
                break;
            }
    }
    while(scanf("%s",a)!=EOF)
    {
        temp=0;
        for(k=0;k<i;k++)
        {
            if(strcmp(s[k].cat,a)==0)
            {
                for(p=0;s[k].china[p]!= ;p++)
                    printf("%c",s[k].china[p]);
                printf("\n");
                temp=1;
                break;
            }
        }
        if(temp==0)
            printf("eh\n");
    }
    return 0;
}

 

【输入回车结束输入】Language of FatMouse

标签:

原文地址:http://www.cnblogs.com/zhangfengnick/p/4427815.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!