poj_2503(map映射)
题目链接poj2503
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 38820 | Accepted: 16578 |
Description
Input
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
Sample Input
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay
Sample Output
cat
eh
loops
Hint
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映射)的更多相关文章
- ZOJ 3644 Kitty's Game dfs,记忆化搜索,map映射 难度:2
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4834 从点1出发,假设现在在i,点数为sta,则下一步的点数必然不能是sta的 ...
- POJ2503——Babelfish(map映射+string字符串)
Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incom ...
- map——映射(message.cpp)
信息交换 (message.cpp) [题目描述] Byteland战火又起,农夫John派他的奶牛潜入敌国获取情报信息. Cow历尽千辛万苦终于将敌国的编码规则总结如下: 1 编码是由大写字母组成的 ...
- filter过滤器与map映射
filter过滤器 >>> list(filter(None,[0,1,2,True,False])) [1, 2, True] filter的作用就是后面的数据按照前面的表达式运算 ...
- map映射
采集于:https://blog.csdn.net/luanpeng825485697/article/details/78056312 映射map: var map = new Map(); //映 ...
- Java精选笔记_集合【Map(映射)接口】
Map(映射)接口 简介 该集合存储键值对,一对一对的往里存,并且键是唯一的.要保证map集合中键的唯一性. 从Map集合中访问元素时,只要指定了Key,就能找到对应的Value. 关键字是以后用于检 ...
- UVA12096 - The SetStack Computer(set + map映射)
UVA12096 - The SetStack Computer(set + map映射) 题目链接 题目大意:有五个动作: push : 把一个空集合{}放到栈顶. dup : 把栈顶的集合取出来, ...
- PHP转Go系列:map映射
映射的定义 初识映射会很懵,因为在PHP中没有映射类型的定义.其实没那么复杂,任何复杂的类型在PHP中都可以用数组表示,映射也不例外. $array['name'] = '平也'; $array['s ...
- Reactor系列(五)map映射
#java# #reactor# #flux# #map# #映射# 视频解视: https://www.bilibili.com/video/av79179444/ FluxMonoTestCase ...
随机推荐
- 我与 windows kernel 的一段时光
写在前面 本科毕业设计是实现一个基于 windows 的透明加密过滤系统.由此对 windows kernel development,尤其是 file system 进行过较为深入的探索.对于防终止 ...
- bzoj 3996: [TJOI2015]线性代数
Description 给出一个N*N的矩阵B和一个1*N的矩阵C.求出一个1*N的01矩阵A.使得 D=(A*B-C)*A^T最大.其中A^T为A的转置.输出D Input 第一行输入一个整数N,接 ...
- CentOS5 可用yum源
[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever& ...
- Golang fmt包使用小技巧
h1 { margin-top: 0.6cm; margin-bottom: 0.58cm; direction: ltr; color: #000000; line-height: 200%; te ...
- 聊聊API网关的作用
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 10.5px "Trebuchet MS" } p.p2 { margin: 0.0px ...
- 对 Java 集合的巧妙利用
我们直接切入正题.首先大致介绍一下 Java 三大集合的一些特征: ①.ArrayList:底层采用数组结构,里面添加的元素有序可以重复. ②.HashSet:底层采用哈希表算法,里面添加的元素无序不 ...
- C语言学生管理系统(增进版)
在原版上进行改进,主要改进的功能有. 1.利用atof:将字符串转换为浮点型: 利用atoi:将字符串转换为整型: 原文地址:http://www.cnblogs.com/sddai/p/577412 ...
- Django_form
Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 1.创建Form类 # 创建一个类 from ...
- python科学计算_numpy_ndarray
ndarray:n-dimensional array object,即多维数组对象,是python自带的array对象的扩展,array对象和list对象的区别是array对象的每一个元素都是数值, ...
- sublime自动保存(失去焦点自动保存)
sublime是轻量的编辑器,经常用sublime编辑器来做一些小例子,使用起来很方便. 在使用sublime的时候需要不断的 ctrl + s 保存代码,才能看到效果. 这样的操作很繁琐,保存的多了 ...