题目链接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

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

/*题目大意:给定一系列外国单词,都对应着英语单词。然后给一个外国单词,要求输出相对应的英语单词。若不存在则输出eh
算法分析:可以根据map的映射关系
*/ #include <iostream>
#include <map>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std; int main() {
map <string, bool> appear; //记录单词是否出现
map <string , string > p; //单词映射 char t;
while (true) {
char english[20];
char t; //临时字符
t = getchar();
if (t == '\n') break; //如果是换行符,跳出
int i = 1;
english[0] = t;
while (true) {
t = getchar();
if (t == ' ') {
english[i] = '\0';
break;
}
else english[i++] = t;
}
string forign;
cin >> forign;
getchar(); //吃掉换行符
appear[forign] = true;
p[forign] = english;
}
string word;
while (cin >> word) {
if (appear[word]) cout << p[word] << endl;
else cout << "eh" << endl;
}
return 0;
}

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. SpringMVC随笔记录

    在web.xml里可以配置webapp的默认首页,格式如下: <welcome-file-list> <welcome-file>index.html</welcome- ...

  2. boost::algorithm(字符串算法库)

    没什么说的,需要 #include<boost/algorithm/string.hpp> 1.大小写转换 std::string s("test string"); ...

  3. Xamarin android spinner的使用方法

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  4. ArcGIS API for JavaScript 4.2学习笔记[16] 弹窗自定义功能按钮及为要素自定义按钮(第五章完结)

    这节对Popups这一章的最后两个例子进行介绍和解析. 第一个[Popup Actions]介绍了弹窗中如何自定义工具按钮(名为actions),以PopupTemplate+FeatureLayer ...

  5. Neo4j学习笔记(1)——使用API编写一个Hello World程序

    项目的创建及配置 因为Neo4j依赖的jar包比较多,所以推荐使用Maven来管理. 首先创建一个Maven Project,添加依赖: <dependency> <groupId& ...

  6. C# new关键字和对象类型转换(双括号、is操作符、as操作符)

    一.new关键字 CLR要求所有的对象都通过new来创建,代码如下: Object obj=new Object(); 以下是new操作符做的事情 1.计算类型及其所有基类型(一直到System.Ob ...

  7. js获取手机屏幕宽度、高度

    网页可见区域宽:document.body.clientWidth 网页可见区域高:document.body.clientHeight 网页可见区域宽:document.body.offsetWid ...

  8. 在QComboBox的基础上实现复选功能

    这个是最近的一个项目上需要实现的功能.要求如下: 下拉列表的项目可以多选 显示框不能编辑 所选中的项目在显示框中出现 下面根据网上的提示代码(参照博客 一去二三里),主要实现如下代码(与参照略有不同) ...

  9. MHA高可用架构与Atlas读写分离

    1.1 MHA简介 1.1.1 MHA软件介绍 MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton ...

  10. golang 多维数组

    具体的题目如下:(就是将多维数组的行列互换) A multi-dimensional array is an array of arrays. 2-dimensional arrays are the ...