• POJ2503——Babelfish


    Description

    You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

    Input

    Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, 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. Foreign 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
    


    分析:map学习笔记

    #include<iostream>
    #include<string.h>
    #include<stdio.h>
    #include<ctype.h>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<set>
    #include<math.h>
    #include<vector>
    #include<map>
    #include<deque>
    #include<list>
    using namespace std;
    char s[200];
    char s1[200],s2[200];
    int main()
    {
        map<string,string>m;
        while(gets(s))
        {
            if(strlen(s)==0)
            break;
             sscanf(s,"%s%s",s1,s2);
             m[s2]=s1;//映射
        }
        while(gets(s))
        {
            if(m[s].length()==0)
            puts("eh");
            else
            cout<<m[s]<<endl;
        }
        return 0;
    }
    


  • 相关阅读:
    代码模板
    DNSget Ip
    WC约束示使用
    下雨了
    Xml文件保存值不能及时更新
    代码不是艺术,而是达到目的的一种手段
    网站TCP链接暴增
    吐个槽吧
    正则表达式使用小注意
    Sereja and Two Sequences CodeForces
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3372056.html
Copyright © 2020-2023  润新知