-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP10282.cpp
55 lines (52 loc) · 1.08 KB
/
P10282.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
#include <iostream>
#include <stdio.h>
#include <map>
#include <sstream>
typedef std::map<std::string,std::string> map;
int main() {
map dic;
// Read dictionary:
char line[23];
while(true) {
std::cin.getline(line, 23);
std::string a, b;
int part = -1;
for(int i = 0; i < 23; ++i) {
if(part == -1) {
if(line[i] == ' ') {
line[i] = '\0';
a = std::string(line);
part = i+1;
continue;
}
if(!(line[i] >= 'a' && line[i] <= 'z')) {
break;
}
}
else {
if(!(line[i] >= 'a' && line[i] <= 'z')) {
line[i] = '\0';
b = std::string(&line[part]);
break;
}
}
}
if(part == -1)
break;
dic.insert(std::make_pair(b, a));
//std::cerr << "Read " << a << " -> " << b << std::endl;
}
while(std::cin.getline(line, 12)) {
for(int i = 0; i < 12; ++i) {
if(!(line[i] >= 'a' && line[i] <= 'z')) {
line[i] = '\0';
break;
}
}
map::const_iterator it = dic.find(std::string(line));
if(it == dic.end())
std::cout << "eh" << std::endl;
else
std::cout << it->second << std::endl;
}
}