题目描述

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)的更多相关文章

  1. POJ 2503 Babelfish (STL)

    题目链接 Description You have just moved from Waterloo to a big city. The people here speak an incompreh ...

  2. xtu字符串 A. Babelfish

    A. Babelfish Time Limit: 3000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class ...

  3. 详细解说 STL 排序(Sort)

    0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...

  4. STL标准模板库(简介)

    标准模板库(STL,Standard Template Library)是C++标准库的重要组成部分,包含了诸多在计算机科学领域里所常见的基本数据结构和基本算法,为广大C++程序员提供了一个可扩展的应 ...

  5. STL的std::find和std::find_if

    std::find是用来查找容器元素算法,但是它只能查找容器元素为基本数据类型,如果想要查找类类型,应该使用find_if. 小例子: #include "stdafx.h" #i ...

  6. STL: unordered_map 自定义键值使用

    使用Windows下 RECT 类型做unordered_map 键值 1. Hash 函数 计算自定义类型的hash值. struct hash_RECT { size_t operator()(c ...

  7. C++ STL简述

    前言 最近要找工作,免不得要有一番笔试,今年好像突然就都流行在线笔试了,真是搞的我一塌糊涂.有的公司呢,不支持Python,Java我也不会,C有些数据结构又有些复杂,所以是时候把STL再看一遍了-不 ...

  8. codevs 1285 二叉查找树STL基本用法

    C++STL库的set就是一个二叉查找树,并且支持结构体. 在写结构体式的二叉查找树时,需要在结构体里面定义操作符 < ,因为需要比较. set经常会用到迭代器,这里说明一下迭代器:可以类似的把 ...

  9. STL bind1st bind2nd详解

    STL bind1st bind2nd详解   先不要被吓到,其实这两个配接器很简单.首先,他们都在头文件<functional>中定义.其次,bind就是绑定的意思,而1st就代表fir ...

随机推荐

  1. 为什么Redis比Memcached易

    GitHub版本号地址: https://github.com/cncounter/translation/blob/master/tiemao_2014/Redis_beats_Memcached/ ...

  2. Nubia Z5S 官方4.4 201内測版 内核版本号信息

    从egl推断内核的的版本号: OpenGL ES Shader Compiler Version: E031.24.00.14 Build Date: 04/29/14 Tue Local Branc ...

  3. spring mvc综合easyui点击上面菜单栏中的菜单项问题

    采用easyui的tree报错发生的背景后,会弹出一个窗口,有一个问题是,当你点击顶部   解决方案,如下面(运用easyui1.36): /home/cyz/workspace/hb_manager ...

  4. 有向图的邻接矩阵表示法(创建,DFS,BFS)

    package shiyan; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; publi ...

  5. tomcatport占用,如何识别和kill

    开始-执行-cmd,进netstat -ano你可以看到整个port入住. 增加要想知道谁占用了我们的port8080,输入下面命令 C:\Documents and Settings\Adminis ...

  6. Spring-MVC4 + JPA2 + MySql-5.5 + SLF4J + JBoss WildFly-8.1开发环境的搭建

    面试被问Spring4,它的目的是把过去Spring3所有升级项目Spring4.现在将记录在此环境搭建过程. 第一次使用Maven Archetype创建一个项目框架,运行以下命令: mvn arc ...

  7. BizTalk开发小技巧

    BizTalk开发小技巧 随笔分类 - Biztalk Biztalk 使用BizTalk实现RosettaNet B2B So Easy 摘要: 使用BizTalk实现RosettaNet B2B ...

  8. React.js入门笔记 创建hello world 的6种方式

    一.ReactJS简介 React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站. ...

  9. js 滚轮事件 滚轮焦点图(轮播图)

    利用滚轮,切换轮播图.附带mousewheel插件以及原生js写法:   <!doctype html> <html> <head> <meta charse ...

  10. MessageFormat类别:快速格式化字符串

    MessageFormat 获取一组对象,格这些对象的类型,然后格串类型插入的地方的图案. 第一个样例使用静态的方法 MessageFormat.format.它在内部创建一个仅仅使用一次的 Mess ...