zoukankan      html  css  js  c++  java
  • Babelfish

    题目描述

    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 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 is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh". 

    样例输入

    dog ogday
    cat atcay
    pig igpay
    froot ootfray
    loops oopslay
    
    atcay
    ittenkay
    oopslay
    

    样例输出

    cat
    eh
    loops
    

    提示

    Huge input and output,scanf and printf are recommended.

     
    题目大意:事先给你一些字典中一个单词对应的字符串  然后询问一些字符串输出对应的字典单词   如果找不到输出eh
    利用STL中的map
     
    输入感觉很麻烦 转载于https://blog.csdn.net/keshuai19940722/article/details/9991699
     
    sscanf与scanf类似,都是用于输入的,只是后者以键盘(stdin)为输入源,前者以固定字符串为输入源。
    #include <iostream>
    #include <string>
    #include <map>
    #include <cstdio>
    
    using namespace std;
    const int maxn = 1005;
    
    int main()
    {
        map<string,string> m;
        char str[maxn];
        char word[maxn];
        char ans[maxn];
        while(gets(str)&&str[0]!='')
        {
            sscanf(str,"%s%s",ans,word);
            m.insert(pair<string,string>(word,ans));
        }
        char q[maxn];
        while(gets(q))
        {
            if(m.find(q)==m.end())
                cout<<"eh"<<endl;
            else
                cout<<m[q]<<endl;
        }
        return 0;
    }

    如果找不到    它返回的迭代器等于end函数返回的迭代器

  • 相关阅读:
    Mybatis在oracle批量更新
    WebService小记
    java基本排序
    ant使用
    python 集合
    amazon-aws 使用 SNS 发送短信
    Html5+ 开发APP 后台运行代码
    CentOS7 -防火墙
    java 模拟表单方式提交上传文件
    修改pom项目版本 jenkins 关联 shell命令
  • 原文地址:https://www.cnblogs.com/hao-tian/p/9439257.html
Copyright © 2011-2022 走看看