欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

查找之在线翻译

程序员文章站 2022-05-28 12:10:41
...

查找之在线翻译

#include <iostream>
#include <memory.h>
#include <math.h>
#include <stdio.h>
#include <unordered_map>
#include <string>
#include <map>
using namespace std;
map <string,string> mymap;
int main()
{
    while(1)
    {
        string a,b;
        cin >> a >> b;
        mymap[b] = a;
        cin.get();//去掉行末的换行符
        if( cin.peek() == '\n' )//查看是否是空行
            break;
    }
    string temp;
    while( cin >> temp )
    {
        if( mymap.find( temp ) != mymap.end() )
        {
            cout << mymap[temp] <<endl;
        }
        else
            cout << "eh" <<endl;
    }
    return 0;
}