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;
    }
    


  • 相关阅读:
    排列组合
    从$a_n=f(n)$的角度理解数列中的表达式$a_{n+1}=frac{k}{a_n}$
    洛必达法则的应用
    三角函数专题
    和差角公式的证明
    利用导数证明不等式
    常用数学模型整理
    教给学生知识的本源
    争鸣|两个易混概率题
    es6数组的复制
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3372056.html
Copyright © 2011-2022 走看看