题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1223
Time Limit: 3000MS Memory Limit: 65536K

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.

输入内容包括多达100,000个字典条目,后面是一个空行,后面是一条多达100,000个单词的消息。每个字典条目都是一行,包含一个英语单词,后跟一个空格和一个外语单词。字典里没有外文词出现过一次。信息是外语中的一系列单词,每行一个单词。输入中的每个单词都是最多10个小写字母的序列。

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

输出是翻译成英文的消息,每行一个字。字典中没有的外来词应译为“eh”。

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

Problem solving report:

Description: 根据外语查找英语。
Problem solving: 直接用STL中的map。

#include <bits/stdc++.h>
using namespace std;
int main() {
    string a, b;
    char str[30], str1[15], str2[15];
    map <string, string> mp;
    while (scanf("%[^\n]", str)) {
    	getchar();
    	sscanf(str, "%s%s", str1, str2);
    	mp[str2] = str1;
    }
    while (~scanf("%s", str)) {
    	if (mp.find(str) != mp.end())
        	printf("%s\n", mp[str].c_str());
    	else printf("eh\n");
    }
    return 0;
}