-
Notifications
You must be signed in to change notification settings - Fork 0
/
poj2503.cpp
57 lines (50 loc) · 1.17 KB
/
poj2503.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Problem: 2503, Babelfish
* User: LoiteringLeo
* Memory: 14689K Time: 2422MS
* Language: G++ Result: Accepted
*/
#include <map>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
#define MAX_LEN 11
char input[MAX_LEN];
int main()
{
map<string, string> dict;
map<string, string>::iterator it;
char *foreign;
char *local;
bool query = false;
while (gets(input)) {
if (query == false) {
if (strlen(input) == 0) {
query = true;
}
else {
local = input;
foreign = strchr(input, ' ');
*foreign = '\0';
foreign++;
dict.insert(
pair<string, string>(string(foreign), string(local)));
}
}
else {
if (input[0] == '\0') {
break;
}
it = dict.find(string(input));
if (it != dict.end()) {
printf("%s\n", it->second.c_str());
}
else {
printf("eh\n");
}
foreign[0] = '\0';
}
}
return 0;
}