博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[POJ2503]Babelfish
阅读量:5041 次
发布时间:2019-06-12

本文共 2318 字,大约阅读时间需要 7 分钟。

题目链接:http://poj.org/problem?id=2503

 

 

 
 

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 ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay

Sample Output

catehloops

Hint

Huge input and output,scanf and printf are recommended.

Source

 

 

STL撸过,重要的是输入的处理。

 

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 14 using namespace std;15 16 typedef map
mss;17 typedef pair
pss;18 mss dic;19 pss tmp;20 char a[110];21 char b[110];22 char buf[80];23 24 int main() {25 // freopen("in", "r", stdin);26 // ios::sync_with_stdio(false);27 while(gets(buf)) {28 int flag = 0;29 int cnt = 0;30 int sflag = 0;31 for(int i = 0; buf[i]; i++) {32 if(flag) {33 if(sflag && buf[i] == ' ') {34 continue;35 }36 b[cnt++] = buf[i];37 }38 else { 39 if(buf[i] != ' ') {40 a[cnt++] = buf[i];41 sflag = 1;42 }43 else {44 flag = 1;45 cnt = 0;46 }47 }48 }49 tmp = make_pair(b, a);50 dic.insert(tmp);51 if(!flag) {52 break;53 }54 memset(a, 0, sizeof(a));55 memset(b, 0, sizeof(b));56 memset(buf, 0, sizeof(buf));57 }58 // for(mss::iterator it = dic.begin(); it != dic.end(); it++) {59 // cout << it->first << " " << it->second << endl;60 // }61 while(~scanf("%s", buf)) {62 if(dic.find(buf) != dic.end()) {63 // cout << dic[buf] << endl;64 printf("%s\n", dic[buf].data());65 }66 else {67 printf("eh\n");68 }69 }70 return 0;71 }

 

转载于:https://www.cnblogs.com/kirai/p/4761435.html

你可能感兴趣的文章
80X86寄存器详解<转载>
查看>>
c# aop讲解
查看>>
iterable与iterator
查看>>
返回顶部(动画)
查看>>
webpack+react+antd 单页面应用实例
查看>>
Confluence 6 SQL Server 数据库驱动修改
查看>>
Confluence 6 通过 SSL 或 HTTPS 运行 - 备注和问题解决
查看>>
【47.76%】【Round #380B】Spotlights
查看>>
Git(使用码云)
查看>>
分享Java web 开发必游之路
查看>>
IIS初始化(预加载),解决第一次访问慢,程序池被回收问题(转载)
查看>>
Bean的Scope
查看>>
【BZOJ】3142: [Hnoi2013]数列
查看>>
http初探
查看>>
elasticsearch的安装
查看>>
__next__()
查看>>
爬取:中国大学排名
查看>>
聊天室(C++客户端+Pyhton服务器)_1.框架搭设
查看>>
UpdatePanel 内控件 更新“外的”控件【转】
查看>>
mybatis中&gt;=和&lt;=的实现方式
查看>>