1.Link:

http://poj.org/problem?id=2503

http://bailian.openjudge.cn/practice/2503/

2.Content:

Babelfish
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 32783   Accepted: 14093

Description

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

Hint

Huge input and output,scanf and printf are recommended.

Source

3.Method:

4.Code:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib> using namespace std; #define MAX_LENGTH 11
#define MAX_CONTENT 100002 struct dic
{
char key[MAX_LENGTH];
char value[MAX_LENGTH];
}a[MAX_CONTENT]; int mycmp(const void *x,const void *y)
{
return strcmp(((dic*)x)->key,((dic*)y)->key);
} int mycmp_bsearch(const void *x,const void *y)
{
return strcmp((char*)x,((dic*)y)->key);
} int main()
{
char key[MAX_LENGTH],value[MAX_LENGTH];
dic* result;
int i=;
while((value[]=getchar())!='\n')
{
scanf("%s %s",value+,key);
strcpy(a[i].key,key);
strcpy(a[i++].value,value);
getchar();
} qsort(a,i,sizeof(dic),mycmp); while(scanf("%s",key)!=EOF)
{
result=(dic*)bsearch(key,a,i,sizeof(dic),mycmp_bsearch);
if(result==NULL) printf("eh\n");
else printf("%s\n",result->value);
}
//system("pause");
return ;
}

5.Reference:

Poj 2503 / OpenJudge 2503 Babelfish的更多相关文章

  1. Poj 2109 / OpenJudge 2109 Power of Cryptography

    1.Link: http://poj.org/problem?id=2109 http://bailian.openjudge.cn/practice/2109/ 2.Content: Power o ...

  2. Poj 1328 / OpenJudge 1328 Radar Installation

    1.Link: http://poj.org/problem?id=1328 http://bailian.openjudge.cn/practice/1328/ 2.Content: Radar I ...

  3. Poj 2262 / OpenJudge 2262 Goldbach's Conjecture

    1.Link: http://poj.org/problem?id=2262 http://bailian.openjudge.cn/practice/2262 2.Content: Goldbach ...

  4. Poj 2159 / OpenJudge 2159 Ancient Cipher

    1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...

  5. Poj 1017 / OpenJudge 1017 Packets/装箱问题

    1.链接地址: http://poj.org/problem?id=1017 http://bailian.openjudge.cn/practice/1017 2.题目: 总时间限制: 1000ms ...

  6. Poj 1001 / OpenJudge 2951 Exponentiation

    1.链接地址: http://poj.org/problem?id=1001 http://bailian.openjudge.cn/practice/2951 2.题目: Exponentiatio ...

  7. Poj 1006 / OpenJudge 2977 1006 Biorhythms/生理周期

    1.链接地址: http://poj.org/problem?id=1006 http://bailian.openjudge.cn/practice/2977 2.题目: Biorhythms Ti ...

  8. Poj 2586 / OpenJudge 2586 Y2K Accounting Bug

    1.Link: http://poj.org/problem?id=2586 2.Content: Y2K Accounting Bug Time Limit: 1000MS   Memory Lim ...

  9. Redis-cluster集群【第四篇】:redis-cluster集群配置

    Redis分片: 为什么要分片:随着Redis存储的数据越来越庞大,会导致Redis的性能越来越差! 目前分片的方法: 1.客户端分片 在应用层面分片,程序里指定什么数据存放在那个Redis  优势: ...

随机推荐

  1. delphi 中DLL的建立

    Dll的创建与调用   File ->New->Other->Dll Wizard  DLL的创建 //可以将本代码复制粘贴到项目中 library Project1; uses S ...

  2. 3款强大的BootStrap的可视化制作工具推荐

    http://www.25xt.com/html5css3/7342.html 25学堂看到最近很多朋友在学习Bootstrap前端主题框架.顾让25学堂的小编给大家找来了3款适合Bootstrap初 ...

  3. Pimp_my_Z1

    https://github.com/Androguide/Pimp_my_Z1 Pimp_my_Z1-master.zip

  4. 怎样拷贝整个目录并且忽略部分文件及目录(包括windows)

    http://www.dewen.org/q/2150 rsync -a --exclude dir1 --exclude dir2 ... source target

  5. MediaPlayer开发全解析

    本文介绍MediaPlayer的使用.MediaPlayer可以播放音频和视频,另外也可以通过VideoView来播放视频,虽然VideoView比MediaPlayer简单易用,但定制性不如用Med ...

  6. Swift3.0语法变化

    写在前面 首先和大家分享一下学习新语法的技巧:用Xcode8打开自己的Swift2.3的项目,选择Edit->Convert->To Current Swift Syntax- 让Xcod ...

  7. divide-conquer-combine(4.1 from the introduction to algorithm)

    this example is from chapter 4 in <the introduction to algorithm> the main idea is all showed ...

  8. UVA 10006 - Carmichael Numbers 数论(快速幂取模 + 筛法求素数)

      Carmichael Numbers  An important topic nowadays in computer science is cryptography. Some people e ...

  9. Http Message Converters with the Spring Framework--转载

    原文:http://www.baeldung.com/spring-httpmessageconverter-rest 1. Overview This article describes how t ...

  10. EXTJS 常用控件的使用

    重要按钮配置项 handler: renderTo: 取得控件及其值 var memo = form.findById('memo');//取得输入控件 alert(memo.getValue()); ...