#include <iostream>
#include <map>
#include <string>
#include <stdio.h>
using namespace std;
//程序引用了c++标准库的类模板 map,这个模板貌似是基于散列算法的(由于不想自己写hash……),不过程序效率不太高啦
int main()
{
map<string, string> dic; // 建立string 到 string 的映射 dic
string translated, vocabulary;
while(true)
{
cin >> translated >> vocabulary;
dic[vocabulary] = translated;
if(cin.peek() == '\n') // 探测输入流下一个指针不是指向'\n'
{
break;
}
}
string text;
while(scanf("%s", text))
{
if(dic.find(text) != dic.end())
{
printf("%s\n", dic[text]);
}
else
{
printf("eh\n");
}
}
}
词典
最新推荐文章于 2025-07-31 11:43:21 发布
