首页 > 代码库 > 词典 (noi OpenJudge)

词典 (noi OpenJudge)

 

  传送门:1806:词典

  神奇的STL

 

技术分享

技术分享

 

 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map> 
#include <sstream>
using namespace std;
string s, s1, s2, word;
map <string, string> dic;
int main()
{
    while (getline (cin, s) && s != "")
    {
        stringstream sin (s);
        sin >> s1 >> s2;
        dic [s2] = s1;
    }
    while (cin >> word)
    {
        if (dic [word] == "")
            cout << "eh" << endl;
        else 
            cout << dic [word] << endl;
    }
    return 0;
}

 

词典 (noi OpenJudge)