题目连接:

acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1109 

题目描述:

We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.

Input Specification

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

Output Specification

Output is the message translated to English, one word per line. FatMouse 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

Output for Sample Input

cat
eh
loops
 /*问题 输入两种语言的对照表及带查询单词,查找并输出对应的语言的单词
解题思路 使用map映照容器。用gets()读取空行为分割*/
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std; int main()
{
string s;
map<string,string> m;
map<string,string>::iterator it;
char ss[],s1[],s2[]; /*gets函数的用法
gets要比cin.getline的速度快的多,单gets不能从cin中读取数据,调试不易
它从stdin中读取字符串,知道接受换行符或者EOF时停止,另外换行符不作为读取串的内容,读取的换行符被转化成
NULL值,并由此来结束字符串*/ while(gets(ss))
{
s=ss;
if(s=="") break; sscanf(ss,"%s %s",s1,s2);
m[s2]=s1;//以鼠国语为键值,因为查询时输入的是鼠国语
}
while(gets(ss))
{
s=ss;
it=m.find(s);
if(it != m.end())
cout<<(*it).second<<endl;
else
printf("eh\n");
}
return ;
}

最新文章

  1. BFC?来自CSS中的BFC
  2. java中string内存的相关知识点
  3. Color国际青年公寓
  4. 根据 MySQL 状态优化 ---- 3. key_buffer_size
  5. nessus网页报错: Scans can not be saved without a policy. Please create a policy before proce
  6. win2003 多域名绑定一个ip
  7. 【翻译】MVC Music Store 教程-概述(一)
  8. POJ 3481 &amp;amp; HDU 1908 Double Queue (map运用)
  9. Android锁定EditText内容和随机生成验证码
  10. U盘安装Win7
  11. 关于python 函数参数
  12. Linux.杀毒.Centos安装杀毒软件Clam
  13. 微信公众号tp3.2放进Model无效,几种实例化的方法试过,还是提示无法提供服务
  14. python两个列表合并为字典,一个作为key,一个作为value
  15. (记忆化搜索)数塔 (zznu 1271)
  16. MyEclipse WebSphere开发教程:WebSphere 7安装指南(二)
  17. [label][Chrome-Extension] How to start Chrome Extension&#39;s development
  18. EBS Certifications
  19. hive-show-partitions
  20. caffe搭建以及初步学习--win7-vs2013-gtx650tiboost-cuda8.0-cifar10训练和测试-2-快速解决方案cifar10_quick_solver.prototxt

热门文章

  1. Linux Shell学习笔记:exit退出状态代码
  2. 验证手机格式的js代码
  3. spring boot学习笔记2
  4. sentiwordnet的简单使用
  5. Winform解决界面重绘闪烁的问题
  6. python--partial偏函数
  7. Linux防火墙配置与管理(16)
  8. 在redis中使用lua脚本
  9. 【Spark调优】:RDD持久化策略
  10. 为什么学习linux