Problem C: Babelfish

You have just moved from Waterloo to a big city. The people here speakan incomprehensible dialect of a foreign language. Fortunately, you havea dictionary to help you understand them.

Input consists of up to 100,000 dictionary entries, followed by a blankline, followed by a message of up to 100,000 words. Each dictionaryentry is a line containing an English word, followed by a space and aforeign language word. No foreign word appears more than once in thedictionary. 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 10lowercase letters.Output is the message translated to English, one word per line. Foreignwords not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay

Output for Sample Input

cat
eh
loops

题意: 这么短的题目还用我解释?

解法: 按出题者意思是要用哈希算法, 但是可用STL中的map

AC代码:

#include<stdio.h>
#include<iostream>
#include<string>
#include<map> using namespace std; char str1[30];
char str2[30];
char str[50]; map<string, string> Map; int main() {
Map.clear(); while(gets(str) != NULL) {
if(str[0] == '\0')
break;
sscanf(str, "%s %s", str1, str2);
Map[str2] = str1;
} while(scanf("%s", str) != EOF) {
if(Map.find(str) != Map.end())
cout<< Map[str] <<endl;
else
printf("eh\n");
}
return 0;
}

UVA 10282 (13.08.18)的更多相关文章

  1. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  2. UVA 253 (13.08.06)

     Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blu ...

  3. UVA 573 (13.08.06)

     The Snail  A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...

  4. UVA 10499 (13.08.06)

    Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...

  5. UVA 10025 (13.08.06)

     The ? 1 ? 2 ? ... ? n = k problem  Theproblem Given the following formula, one can set operators '+ ...

  6. UVA 465 (13.08.02)

     Overflow  Write a program that reads an expression consisting of twonon-negative integer and an ope ...

  7. UVA 10494 (13.08.02)

    点此连接到UVA10494 思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码: #include<stdio.h> #include<string.h> ...

  8. UVA 424 (13.08.02)

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...

  9. UVA 10106 (13.08.02)

     Product  The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...

随机推荐

  1. eclipse里添加类似myeclipse打开当前操作目录

    1.开打eclipse ide,依次run->external tools->external tools configuration 2.在Program下,new一个自己定义的prog ...

  2. 盒子模型&position定位

    有时候深深的感觉语文这门课程其实很有用, 至少以前学的时候没有感觉到 直到现在阅读大量的别人的资料文章的时候或者是看一些题目....... 总之:认真阅读小心品味 当然,前面的孤言自语和本文无关,只是 ...

  3. 网络爬虫(3)--Beautiful页面解析

            前面2节中对页面内容的访问都是直接通过标签访问的,这样虽然也可以达到解析页面内容的目的,但是在网页复杂,页面结构发生变化时,爬虫就失效了.为了使爬虫能够更加鲁棒的工作,我们需要学习通过 ...

  4. Spring 反转控制(IOC) 依赖注入(DI)

    简单的理解: 之前是我为了完成业务A 需要某个对象B的支持 那么我在这个业务A中就会创建一个对象B使用,说白了就是我根据需求来控制对象B, 而spring的ioc把对象B的控制权从业务A手中拿到自己手 ...

  5. Andriod布局之LinearLayout

    LinearLayout是安卓中的常见布局,即线性布局.(提示:在Andriod中要常用alt+/快捷键来补全代码 其中有一个重要的属性android:orientation,它是表示线性布局的方向问 ...

  6. 面试前的准备---C#知识点回顾----02

    经过昨天大量的简历投递,今天陆续收到面试邀约,明日准备大战一场,是死是活一试便知 1.数据库的范式 这算入门问题了吧,但凡是个数据库类的,都得问吧, 但我们在回答的时候开始背书啦 第一范式(1NF)无 ...

  7. 解决ActiveX Control异常:"没有注册类(异常来自 HRESULT:0x80040154(REGDB_E_CLASSNOTREG))"

    问题背景: 1.我们的程序是用winform调用unity web player 插件来作为播放器在客户端播放动画文件的. 2.播放器是由我们的客户端程序调用的 3.客户端程序默认是以管理员身份启动的 ...

  8. Android零碎知识点总结

    1 简单的跨进程通信可以用Messenger类,不用AIDL. 2 当一个Service没有action时,它默认是exported="false"的,其它进程用它的包名和类名构造 ...

  9. winsock开发重复定义问题

    参考: VS2013使用winsock.h和winsock2.h发生冲突后的终极解决方法:http://www.cnblogs.com/Shirlies/p/5137548.html WINSOCK. ...

  10. (原)Ubuntu14中安装GraphicsMagick

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5661439.html 参考网址: http://comments.gmane.org/gmane.co ...