zoukankan      html  css  js  c++  java
  • 【输入回车结束输入】Language of FatMouse

    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("
    ");
                    temp=1;
                    break;
                }
            }
            if(temp==0)
                printf("eh
    ");
        }
        return 0;
    }
  • 相关阅读:
    session和cookie
    数据库备份
    使用pip安装.whl文件时出现is not a supported wheel on this platform的解决办法
    multiprocessing模块
    threading模块
    python中多线程相关
    python中实现单例模式
    Flask-SQLAlchemy相关与Flask-Migrate相关
    redis模块
    Flask-Login中装饰器@login_manager.user_loader的作用及原理
  • 原文地址:https://www.cnblogs.com/zhangfengnick/p/4427815.html
Copyright © 2011-2022 走看看