题目链接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. 【ASP.NET系列】详解Views

    描述 本片文章内容属于ASP.NET MVC系列视图篇,主要讲解View,大致内容如下: 1.Views文件夹讲解 2.View种类 3.Razor语法 4.对视图的基本操作 一   Views文件夹 ...

  2. MySQL5.6中date和string的转换和比较

    Conversion & Comparison, involving strings and dates in MySQL 5.6 我们有张表,表中有一个字段dpt_date,SQL类型为da ...

  3. python net-snmp 的使用

    这一年一直在做一个综合管控平台的项目,用python写的,项目春节前可能就要进行实际部署了和测试,趁着这个空闲期,回顾一下项目中用到的一些技术,第一个就是SNMP协议. 项目结构主要是实现对ipran ...

  4. DES加解密、JavaScript、Java

    JavaScript代码    DES.js /** * Created by Andy on 2017/11/30. */ /** * DES加密/解密 * @Copyright Copyright ...

  5. rsync服务器的搭建

    Rsync(remote synchronize)是一个远程数据同步工具,简要的概括就是主机于主机之间的文件目录数据的一个同步.下面就是rsync服务器的搭建过程.    系统环境 平台:Centos ...

  6. redis资料收集

    http://www.runoob.com/redis/redis-sets.html  redis set 使用 https://www.cnblogs.com/wanzaixiaoxin/p/49 ...

  7. 浅谈JavaScript的面向对象程序设计(二)

    前面介绍通过Object构造函数或者字面量创建单个对象,但是通过这个的方法创建对象有明显的缺点:调用同一个接口创建多个实例,会产生大量的重复代码.怎么样解决? 工厂模式 工厂模式是软件工程领域经常使用 ...

  8. 最新swift4.0 图片进行尺寸大小及体积压缩

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Menlo; color: #4dbf56; background-color: #282b3 ...

  9. 微信小程序开发之picker选择器组件用法

    picker组件时一个从底部弹起的可滚动的选择器(嵌入页面滚动器组件picker-view查看https://mp.weixin.qq.com/debug/wxadoc/dev/component/p ...

  10. vue2.0 资源文件assets和static的区别

    资源文件处理 在我们的项目结构里,有两个资源文件的路径,分别是:src/assets 和 static/.那这两个到底有什么区别呢? Webpacked 资源 为了回答这个问题,我们首先需要理解web ...