Babelfish (STL)
题目描述
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 oopslay atcay
ittenkay
oopslay
样例输出
cat
eh
loops 代码:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <iomanip>
#include <queue>
#include <stdlib.h>
#include <sstream>
#include <map>
using namespace std; int main()
{
char word[], fword[], str[];
map<string, string> danci; while (gets(str) && str[] != '\0')
{
sscanf(str, "%s%s", word, fword);
danci[fword] = word;
} while (cin >> fword)
{
if (danci.find(fword) != danci.end( ))
cout << danci[fword] << endl;
else
cout << "eh" << endl;
} return ;
}
Babelfish (STL)的更多相关文章
- POJ 2503 Babelfish (STL)
题目链接 Description You have just moved from Waterloo to a big city. The people here speak an incompreh ...
- xtu字符串 A. Babelfish
A. Babelfish Time Limit: 3000ms Memory Limit: 65536KB 64-bit integer IO format: %lld Java class ...
- 详细解说 STL 排序(Sort)
0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...
- STL标准模板库(简介)
标准模板库(STL,Standard Template Library)是C++标准库的重要组成部分,包含了诸多在计算机科学领域里所常见的基本数据结构和基本算法,为广大C++程序员提供了一个可扩展的应 ...
- STL的std::find和std::find_if
std::find是用来查找容器元素算法,但是它只能查找容器元素为基本数据类型,如果想要查找类类型,应该使用find_if. 小例子: #include "stdafx.h" #i ...
- STL: unordered_map 自定义键值使用
使用Windows下 RECT 类型做unordered_map 键值 1. Hash 函数 计算自定义类型的hash值. struct hash_RECT { size_t operator()(c ...
- C++ STL简述
前言 最近要找工作,免不得要有一番笔试,今年好像突然就都流行在线笔试了,真是搞的我一塌糊涂.有的公司呢,不支持Python,Java我也不会,C有些数据结构又有些复杂,所以是时候把STL再看一遍了-不 ...
- codevs 1285 二叉查找树STL基本用法
C++STL库的set就是一个二叉查找树,并且支持结构体. 在写结构体式的二叉查找树时,需要在结构体里面定义操作符 < ,因为需要比较. set经常会用到迭代器,这里说明一下迭代器:可以类似的把 ...
- STL bind1st bind2nd详解
STL bind1st bind2nd详解 先不要被吓到,其实这两个配接器很简单.首先,他们都在头文件<functional>中定义.其次,bind就是绑定的意思,而1st就代表fir ...
随机推荐
- C#使用SqlBulkCopy将DataTable写入数据库的表中(表不存在则创建新表,数据存在则更新,不存在则插入)
原文:.net使用SqlBulkCopy导入数据(创建新表) .net2.0后ado.net提供了一个快速导入sqlserver的方法sqlbulkcopy.导入效率非常高. 包装了一个简单的sql ...
- 程序员---C语言细节7(增加两个整数溢出检测)
主要内容:增加两个整数溢出检测 #include <stdio.h> #include <limits.h> int main(int argc, char *argv[]) ...
- T-SQL中default值的使用
今天介绍一下通过T-SQL语句来创建表时使用default的关键字来自动使用默认值,这个关键字和其它的如:identity,primary key ,not null ,unique等不是相同,这里简 ...
- android看不见main函数怎么办?程序异常了,能够不提示“xxx软件停止执行”吗?
今天遇到了这个问题,分享一下解决方式. android没有main 函数,自然也就不存在main里面加入异常处理来实现全局异常捕获的方案.那android程序有全局异常补货的解决方式吗? 答案是有的: ...
- ArcPad 10 的安装部署
ArcPad是安装在手持设备或者移动终端的一个外业ArcGIS产品,也就是说ArcPad是Esri的一款软件产品,而不是硬件设备哦.尽管不比ArcGIS Desktop功能复杂缤纷,可是对于野外作业. ...
- JFileChooser
http://www.cnblogs.com/dyllove98/archive/2012/03/05/2461895.html package swing.choose; import java.a ...
- MVC 5 Ajax + bootstrap+ handle bar 例: 实现service 状态
Js Script <script src="../../Scripts/handlebars-v1.3.0.js"></script> <scrip ...
- String构造函数originalValue.length>size 它发生
最近观看Jdk6于String源代码被发现String这种施工方法有.源内容如下面: public String(String original) { int size = original.coun ...
- hdu2852--KiKi's K-Number(段树,求第一k的数量)
KiKi's K-Number Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 成不了天才,但为何也没成"人材"?(转)
长期以来,"软件业"一直被视为"智力密集"型的"朝阳"产业,大多数从业者都受过高等教育,其平均素质居于社会各行业的前列,这个产业的顶尖人物被 ...