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;
    }
  • 相关阅读:
    Log4net详细说明
    IDEA 介绍
    在互联网中关系型数据库是否不再那么重要
    彻底删除Kafka中的topic
    kafka consumer 配置详解
    kafka常用命令
    kafka可视化客户端工具Kafka Tool
    System.InvalidOperationException:“线程间操作无效: 从不是创建控件“btnSearch”的线程访问它。
    zookeeper图形化的客户端工具
    window上安装kafka(单机)
  • 原文地址:https://www.cnblogs.com/zhangfengnick/p/4427815.html
Copyright © 2011-2022 走看看