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函数返回的迭代器

  • 相关阅读:
    关于ViewPager、ViewFilpper、ViewFlow三种实现水平向滑动方式的比较
    php 使用curl模拟登录discuz以及模拟发帖
    php 使用curl模拟登录人人(校内)网
    PHP PDO函数库详解
    比CMD更强大的命令行WMIC
    强大的命令行工具wmic
    wmic 命令的一个汇总,功能很强大
    Oracle 11g default profile 默认启用密码过期180天 ORA-28001错误处理
    Oracle 11g密码过期问题解决方案
    SQLPlus 在连接时通常有四种方式
  • 原文地址:https://www.cnblogs.com/hao-tian/p/9439256.html
Copyright © 2011-2022 走看看