zoukankan      html  css  js  c++  java
  • 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;
    }
    


  • 相关阅读:
    回溯算法
    cannot import name 'np' in mxnet
    Linux后台运行任务 nohup &
    为Windows Terminal添加右键菜单
    Outlook设置QQ邮箱
    逻辑回归 logistic regression
    Python添加自定义目录到sys.path
    强化学习 策略梯度
    为Windows terminal preview添加右键菜单
    双系统使用Linux引导
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3372056.html
Copyright © 2011-2022 走看看