#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_WORD_LEN 11
#define MAX_DICTION_ITEM (100000 + 10)
using std::sort;
struct Dictionary{
char szWord[MAX_WORD_LEN];
char szEnglish[MAX_WORD_LEN];
};
Dictionary diction[MAX_DICTION_ITEM];
bool CmpDictionItem(Dictionary one, Dictionary two){
return strcmp(one.szWord, two.szWord) < 0;
}
int FindEnglish(char* pszWord, int nItemNum){
int nBeg = 0, nEnd = nItemNum - 1;
int nCmp = 0;
while (nBeg <= nEnd){
int nMid = (nBeg + nEnd) / 2;
nCmp = strcmp(pszWord, diction[nMid].szWord);
if (nCmp == 0) return nMid;
else if (nCmp < 0) nEnd = nMid - 1;
else nBeg = nMid + 1;
}
return -1;
}
int main(){
char szStr[30];
char szWord[MAX_WORD_LEN];
int nCount = 0;
int nAnsItem = 0;
while (fgets(szStr, 29, stdin), szStr[0] != '\n')
{
sscanf(szStr, "%s%s", diction[nCount].szEnglish, diction[nCount].szWord);
++nCount;
}
sort(diction, diction + nCount, CmpDictionItem);
while (scanf("%s", szWord) == 1)
{
if ((nAnsItem = FindEnglish(szWord, nCount)) != -1)
{
printf("%s\n", diction[nAnsItem].szEnglish);
}
else
{
printf("eh\n");
}
}
return 0;
}
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
char str1[100],t1[100],t2[100];
string eng,fore,s;
map<string,string> dic;
int main(){
while(1){
memset(str1,0,sizeof(str1));
gets(str1);
if(strlen(str1)==0) break;
sscanf(str1,"%s %s",t1,t2);
eng=t1;
fore=t2;
dic[fore]=eng;
}
while(scanf("%s",str1)!=EOF){
s=str1;
if(dic.find(s)==dic.end()) printf("eh\n");
else printf("%s\n",dic[s].c_str());
}
return 0;
}