zoukankan      html  css  js  c++  java
  • POJ2503 -- Babelfish

    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
    

    Hint

    Huge input and output,scanf and printf are recommended.


    我看没有人写不用sscanf()的代码,那我在这里就上传一个不用sscanf的代码吧

    AC代码

    #include <algorithm>
    #include <iostream>
    #include <map>
    #include <string>
    using namespace std;
    string s, ss;
    map<string, string> mp;
    int main() {
        ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
        string s, ss;
        while (getline(cin, s) && s.length() != 0) {
            int pos = s.find(' ');
            mp[s.substr(pos + 1, s.length() - 1)] = s.substr(0, pos);
        }
        while (cin >> s && s.length() != 0) {
            if (mp.find(s) != mp.end()) {
                cout << mp[s] << endl;
            } 
            else
                cout << "eh" << endl;
        }
    
        return 0;
    }
    
  • 相关阅读:
    2016 多校赛3 A 水 B 期望,规律 C 各种博弈 J 物理题,积分 K 暴力,水
    2016 多校赛4 A dp,KMP E(待补) F(待补) J LIS变形,套路 K 水 L 水
    2016-12-27 spoj MINSUB 二分,单调栈 spoj INTSUB 思维
    sqlmap用户手册
    用PROXYCHAINS实现SSH全局代理
    linux之sort用法
    PHP 变量定义及使用
    查漏补缺
    总结2
    最近
  • 原文地址:https://www.cnblogs.com/FrankOu/p/14326691.html
Copyright © 2011-2022 走看看