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


  • 相关阅读:
    AngularJS 最常用的八种功能
    angularJs自定义模块
    angularJs 购物车模型
    angularJs-未加载完成的页面显示混乱ng-bind
    angularJs-脏检查
    angularJs-控制器
    【转载更新】Linux工具之SED 2.应用实例
    【转载更新】Linux工具之SED 1.基础知识
    【转载更新】Linux工具之AWK 4.实例
    【转载更新】Linux工具之AWK 3.高级知识
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3372056.html
Copyright © 2011-2022 走看看