题目描述

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 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 is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

样例输入

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

样例输出

cat
eh
loops

代码:
 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 #include <algorithm>
 5 #include <iostream>
 6 #include <ctype.h>
 7 #include <iomanip>
 8 #include <queue>
 9 #include <stdlib.h>
10 #include <sstream>
11 #include <map>
12 using namespace std;
13
14 int main()
15 {
16     char word[15], fword[15], str[25];
17     map<string, string> danci;
18
19     while (gets(str) && str[0] != '\0')
20     {
21         sscanf(str, "%s%s", word, fword);
22         danci[fword] = word;
23     }
24
25     while (cin >> fword)
26     {
27         if (danci.find(fword) != danci.end( ))
28             cout << danci[fword] << endl;
29         else
30             cout << "eh" << endl;
31     }
32
33     return 0;
34 }

转载于:https://www.cnblogs.com/wangmengmeng/p/5193473.html

Babelfish (STL)相关推荐

  1. 【POJ 2503】Babelfish(水题)stl map存取即可

    题目链接 题目链接 http://poj.org/problem?id=2503 题意 英文A <=> 方言B 输入B,求A Code(G++) #include <iostream ...

  2. Letters比赛第六场1002 Babelfish解题报告

    1002 Babelfish (POJ 2503) 解题思路:字符串的哈希,找一个比较好的hash函数就可以了,冲突时用链表的形式组织.用STL中的map等容器也可以过,不过性能差点. 代码如下: # ...

  3. STL库(C++11)提供的异步执行方法的方式

    在进行并发编程的时候难免会遇到异步执行时候,现代C++标准库提供了几种异步执行的方式,本文收集整理了一下,以备将来翻阅. Thread方式 Thread 是STL提供的一种快捷创建线程的方式,极大方便 ...

  4. C++ 笔记(24)— STL map 类(map实例化、插入、查找、删除)

    1. STL 映射类简介 map 和 multimap 是键-值对容器,支持根据键进行查找,区别在于,后者能够存储重复的键,而前者只能存储唯一的键. 为了实现快速查找, STL map 和 multi ...

  5. C++ 笔记(23)— STL vector 类(实例化 vector、末尾插入、指定位置插入、数组方式访问元素、指针方式访问元素、删除元素、大小与容量区别)

    1. vector 特点 vector 是一个模板类,提供了动态数组的通用功能,具有如下特点: 在数组末尾添加元素所需的时间是固定的,即在末尾插入元素的所需时间不随数组大小而异,在末尾删除元素也如此: ...

  6. C++ 笔记(22)— STL string 类(字符串赋值、访问、拼接、查找、翻转、大小写转换)

    1. 实例化和赋值 STL string #include <string> #include <iostream>int main () {using namespace s ...

  7. C++ 笔记(19)— 标准模板库(STL容器、STL迭代器、STL算法、STL容器特点、STL字符串类)

    C++ 标准库可以分为两部分: 标准函数库: 这个库是由通用的.独立的.不属于任何类的函数组成的.函数库继承自 C 语言. 面向对象类库: 这个库是类及其相关函数的集合. C++ 标准库包含了所有的 ...

  8. STL map 简介

    STL map 简介 转载于:http://www.cnblogs.com/TianFang/archive/2006/12/30/607859.html 1.目录 map简介 map的功能 使用ma ...

  9. 【STL源码剖析读书笔记】【第5章】关联式容器之hashtable

    1.hashtable在插入.删除.搜寻操作上具有"常数平均时间"的表现,不依赖输入元素的随机性. 2.hashtable通过hashfunction将元素映射到不同的位置,但当不 ...

最新文章

  1. python中指定变量为1byte_Python读字节某一位的值,设置某一位的值,二进制位操作...
  2. Oracle EBS-SQL (PO-13):检查采购物料无一揽子协议价格.sql
  3. 小心,信用卡销卡后,竟然变成黑名单!
  4. VSCode Debug API
  5. 自动登录Windows系统
  6. Android实现圆角和圆形
  7. 传智黑马python18期_传智博客黑马Python就业14期资料
  8. 技术岗网上测评-智力题
  9. mysql计算员工年终奖金_年终奖 扣税计算
  10. python---之scipy.ndimage.measurements.label
  11. 【报告分享】2020快手母婴生态报告-快手大数据研究院(附下载)
  12. 分享几个比较通用的学习网站
  13. 2022-2028全球人造黄油结晶器行业调研及趋势分析报告
  14. CTF-RSA1(已知p、q、dp、dq、c)
  15. linux开机自启jar包
  16. 网络摄像机显示管理服务器离线,有看头为什么总是离线 摄像头网络异常解决方法...
  17. CTFHub_历年真题_MISC——“图片修复”、“磁盘恢复”、“蛛丝马迹”
  18. .NET程序中加入Autodesk Design Review 2013 ,打包完成后安装提示未注册XXX.dll解决办法
  19. 华为nova8 se和荣耀30S哪个好
  20. 【LeetCode】3 求最多能有多少个点位于同一直线上

热门文章

  1. 简单聊聊Glide的内存缓存
  2. mongo占用内存过大解决方案
  3. Java对象序列化为什么要使用SerialversionUID
  4. [迷宫中的算法实践]迷宫生成算法——Prim算法
  5. 计算机组成原理——指令流水线
  6. UTF-8编码规则(转)
  7. 三层交换机SVI技术
  8. C++卷积神经网络实例:tiny_cnn代码具体解释(7)——fully_connected_layer层结构类分析...
  9. linux下ifconfig只剩下lo的解决方法
  10. jedis操作redis(二)