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


  • 相关阅读:
    委托、Lamda表达式
    springcloud-feign的hystrix支持
    springcloud-断路器hystrix
    Java原子性、可见性、内存模型
    volatile特性
    synchronized实现可见性
    Js四则运算精度问题处理
    docker 简单安装java web项目
    elasticsearch 分布式集群搭建
    logstash-input-jdbc同时同步多个表
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3372056.html
Copyright © 2011-2022 走看看