POJ 2503 Babelfish (STL)
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
分析:
给定一些单词以及每个单词对应的意思,这之间是一一对应的。然后询问某一个单词对应的意思是什么,如果有对应的意思的话,就把对应的意思输出来,否则输出“eh”。
代码:
#include <iostream>
#include <string>
#include <map>
#include<stdio.h>
using namespace std;
map <string,string>mp;
int main ()
{
char ch[30],str1[15],str2[15];
while (gets(ch))
{
if (ch[0]==0)
break;
sscanf(ch,"%s%s",str1,str2);
mp[str2]=str1;
}
while (gets(ch))
{
map<string,string>::iterator it;
it=mp.find(ch);
if (it!=mp.end())
cout<<(*it).second<<endl;
else
printf("eh\n");
}
return 0;
}
POJ 2503 Babelfish (STL)的更多相关文章
- 题解报告:poj 2503 Babelfish(map)
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensib ...
- poj 2503:Babelfish(字典树,经典题,字典翻译)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30816 Accepted: 13283 Descr ...
- poj 2503 Babelfish(字典树哈希)
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 29059 Accepted: 12565 Description You hav ...
- POJ 2503 Babelfish(map,字典树,快排+二分,hash)
题意:先构造一个词典,然后输入外文单词,输出相应的英语单词. 这道题有4种方法可以做: 1.map 2.字典树 3.快排+二分 4.hash表 参考博客:[解题报告]POJ_2503 字典树,MAP ...
- POJ 2431 Expedition(探险)
POJ 2431 Expedition(探险) Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] A group of co ...
- POJ 3414 Pots(罐子)
POJ 3414 Pots(罐子) Time Limit: 1000MS Memory Limit: 65536K Description - 题目描述 You are given two po ...
- POJ 3281 Dining (网络流)
POJ 3281 Dining (网络流) Description Cows are such finicky eaters. Each cow has a preference for certai ...
- POJ 1847 Tram (最短路径)
POJ 1847 Tram (最短路径) Description Tram network in Zagreb consists of a number of intersections and ra ...
- C++标准模板库(STL)和容器
1.什么是标准模板库(STL)? (1)C++标准模板库与C++标准库的关系 C++标准模板库其实属于C++标准库的一部分,C++标准模板库主要是定义了标准模板的定义与声明,而这些模板主要都是 类模板 ...
随机推荐
- resharper license server
2018-5-14更新 http://jetbrains-a.pw good 2018-4-17 更新 http://jetbrains.tools bad 144.202.4.96 good 201 ...
- dfs和bfs(链式前向星实现)
dfs代码: #include<iostream>#include<Algorithm>#include<cstring>#include<cstdio> ...
- python中 Lambda,Map,Filter,Itertools,Generator高级函数的用法
Lambda 函数 Lambda 函数是一种比较小的匿名函数--匿名是指它实际上没有函数名. Python 函数通常使用 def a_function_name() 样式来定义,但对于 lambda ...
- STM32外设地址查询
问题的提出 DMA传输SDIO驱动的SD卡的数据,其中外设地址的确定 问题的解决 打开数据参考手册,在存储器和总线架构一章存储器映像小节,有一个寄存器组起始地址表,列举所有外设对应的起始地址,再到相应 ...
- Luogu 1315 【NOIP2011】观光公交 (贪心)
Luogu 1315 [NOIP2011]观光公交 (贪心) Description 风景迷人的小城Y 市,拥有n 个美丽的景点.由于慕名而来的游客越来越多,Y 市特意安排了一辆观光公交车,为游客提供 ...
- A1016. Phone Bills
A long-distance telephone company charges its customers by the following rules: Making a long-distan ...
- 【洛谷P4113】采花 HH的项链+
题目大意:静态统计序列区间中出现次数大于等于 2 的颜色数. 题解:类似于HH的项链,只需将 i 和 pre[i] 的关系对应到 pre[i] 和 pre[pre[i]] 的关系即可. 代码如下 #i ...
- 试着用c写了一个多线程的同步
在Java中写多线程相关的程序简单很多,在多线程中需要同步的时候,使用synchronized就行了. 最近学习c的多线程与同步,感觉实现起来,要写的代码比较多一些,这也许是因为java封装的比较好吧 ...
- code::Blocks生成的dll 在 java jni 调用遇到的问题
Test.java__________________________________ public class Test{ public static native void p(); pub ...
- 原生js操作option
<script type="text/javascript"> // 1.动态创建select function createSelect() { var mySele ...