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 |
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <ctime> #include <iomanip> #include <cmath> #include <set> #include <map> #include <stack> using namespace std; map<string,string> dict; int main(){ ios_base::sync_with_stdio(false); string toProc; while (getline(cin,toProc) && toProc.size()) { string eng,dia; int i = 0; for (; i < toProc.size(); i++) { if (toProc[i] == ' ') { i++; break; } eng += toProc[i]; } for (; i < toProc.size(); i++) { dia += toProc[i]; } dict[dia] = eng; } while (cin >> toProc) { string toOut = dict[toProc]; if (toOut.size()) { cout << toOut << endl; }else{ cout << "eh" << endl; } } return 0; } |
这个是拿map水过去的版本,其实应该自己手写一个的。。。