题目链接poj2503

Babelfish
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 38820   Accepted: 16578

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

  1. dog ogday
  2. cat atcay
  3. pig igpay
  4. froot ootfray
  5. loops oopslay
  6.  
  7. atcay
  8. ittenkay
  9. oopslay

Sample Output

  1. cat
  2. eh
  3. loops

Hint

Huge input and output,scanf and printf are recommended.

Source

  1. /*题目大意:给定一系列外国单词,都对应着英语单词。然后给一个外国单词,要求输出相对应的英语单词。若不存在则输出eh
  2. 算法分析:可以根据map的映射关系
  3. */
  4.  
  5. #include <iostream>
  6. #include <map>
  7. #include <string>
  8. #include <cstring>
  9. #include <cstdlib>
  10. #include <cstdio>
  11. using namespace std;
  12.  
  13. int main() {
  14. map <string, bool> appear; //记录单词是否出现
  15. map <string , string > p; //单词映射
  16.  
  17. char t;
  18. while (true) {
  19. char english[20];
  20. char t; //临时字符
  21. t = getchar();
  22. if (t == '\n') break; //如果是换行符,跳出
  23. int i = 1;
  24. english[0] = t;
  25. while (true) {
  26. t = getchar();
  27. if (t == ' ') {
  28. english[i] = '\0';
  29. break;
  30. }
  31. else english[i++] = t;
  32. }
  33. string forign;
  34. cin >> forign;
  35. getchar(); //吃掉换行符
  36. appear[forign] = true;
  37. p[forign] = english;
  38. }
  39. string word;
  40. while (cin >> word) {
  41. if (appear[word]) cout << p[word] << endl;
  42. else cout << "eh" << endl;
  43. }
  44. return 0;
  45. }

poj_2503(map映射)的更多相关文章

  1. ZOJ 3644 Kitty's Game dfs,记忆化搜索,map映射 难度:2

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4834 从点1出发,假设现在在i,点数为sta,则下一步的点数必然不能是sta的 ...

  2. POJ2503——Babelfish(map映射+string字符串)

    Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incom ...

  3. map——映射(message.cpp)

    信息交换 (message.cpp) [题目描述] Byteland战火又起,农夫John派他的奶牛潜入敌国获取情报信息. Cow历尽千辛万苦终于将敌国的编码规则总结如下: 1 编码是由大写字母组成的 ...

  4. filter过滤器与map映射

    filter过滤器 >>> list(filter(None,[0,1,2,True,False])) [1, 2, True] filter的作用就是后面的数据按照前面的表达式运算 ...

  5. map映射

    采集于:https://blog.csdn.net/luanpeng825485697/article/details/78056312 映射map: var map = new Map(); //映 ...

  6. Java精选笔记_集合【Map(映射)接口】

    Map(映射)接口 简介 该集合存储键值对,一对一对的往里存,并且键是唯一的.要保证map集合中键的唯一性. 从Map集合中访问元素时,只要指定了Key,就能找到对应的Value. 关键字是以后用于检 ...

  7. UVA12096 - The SetStack Computer(set + map映射)

    UVA12096 - The SetStack Computer(set + map映射) 题目链接 题目大意:有五个动作: push : 把一个空集合{}放到栈顶. dup : 把栈顶的集合取出来, ...

  8. PHP转Go系列:map映射

    映射的定义 初识映射会很懵,因为在PHP中没有映射类型的定义.其实没那么复杂,任何复杂的类型在PHP中都可以用数组表示,映射也不例外. $array['name'] = '平也'; $array['s ...

  9. Reactor系列(五)map映射

    #java# #reactor# #flux# #map# #映射# 视频解视: https://www.bilibili.com/video/av79179444/ FluxMonoTestCase ...

随机推荐

  1. ArcGIS API for JavaScript 4.2学习笔记[19] 搜索小部件——使用更多数据源

    上一篇中提到,空间搜索小部件是Search这个类的实例化,作为视图的ui属性添加进去后,视图就会出现搜索框了. 这节的主体代码和上篇几乎一致,区别就在上篇提及的sources属性. 先看看结果: 由于 ...

  2. ActiveMQ (一) 初识ActiveMQ

    了解JMS JMS即Java消息服务(Java Message Service)应用程序接口是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进 ...

  3. Qt仿win7自动顶部最大化左侧右侧半屏效果

    Win7系统不得不说是非常好用的,也是目前为止占用份额最大的操作系统,其中win7有个效果,将窗体拖动到顶部时会自动最大化,拖动到左侧右侧时会自动半屏显示,再次拖动窗体到其他位置,会重新恢复之前的大小 ...

  4. Generation Axe 吉他之夜音乐会-广州站 感受

    本人第一次看音乐会,演唱会跟音乐会是有区别的哈,演唱会以表演.舞蹈.歌唱为主,还有很多特别嘉宾 演出时间: 从20点开始一直到23点多才结束,有五个吉他手,开场跟结束五个吉他手一齐演出.平均每个人表演 ...

  5. Linux 使用 cp 命令强制覆盖功能

    Q:我们平常在Linux中使用 cp 命令时,会发现将一个目录中文件复制到另一个目录具有相同文件名称时, 即使添加了 -rf 参数强制覆盖复制时,系统仍然会提示让你一个个的手工输入 y 确认复制,令人 ...

  6. C#图解教程第一章 C#和.NET框架

    1.1 在.NET之前 C#发音:see shap 1.1.1 20世纪90年代后期的Windows编程  20世纪90年代后期各语言缺点:   1.纯Win32 API不是面向对象的,而且工作量比M ...

  7. C#语言和SQL Server第八章笔记

    一:                                                                                                   ...

  8. c3p0使用记录

    首先要导入c3p0包.c3p0下载解压后,lib目录下有三个包,使用mysql的话,只需要导入c3p0-0.9.5.2.jar,mchange-commons-java-0.2.11.jar. 要连接 ...

  9. 什么是ObjCTypes?

    先看一下消息转发流程: 在forwardInvocation这一步,你必须要实现一个方法: - (NSMethodSignature *)methodSignatureForSelector:(SEL ...

  10. input 光标在 chrome下不兼容 解决方案

    input 光标在 chrome下不兼容 解决方案 height: 52px; line-height: normal; line-height:52px\9 .list li input[type= ...