题目连接:

acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1109 

题目描述:

We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.

Input Specification

Input consists of up to 100,005 dictionary entries, followed by a blank line, followed by a message of up to 100,005 words. Each dictionary entry is a line containing an English word, followed by a space and a FatMouse word. No FatMouse word appears more than once in the dictionary. The message is a sequence of words in the language of FatMouse, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output Specification

Output is the message translated to English, one word per line. FatMouse 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

Output for Sample Input

cat
eh
loops
 /*问题 输入两种语言的对照表及带查询单词,查找并输出对应的语言的单词
解题思路 使用map映照容器。用gets()读取空行为分割*/
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std; int main()
{
string s;
map<string,string> m;
map<string,string>::iterator it;
char ss[],s1[],s2[]; /*gets函数的用法
gets要比cin.getline的速度快的多,单gets不能从cin中读取数据,调试不易
它从stdin中读取字符串,知道接受换行符或者EOF时停止,另外换行符不作为读取串的内容,读取的换行符被转化成
NULL值,并由此来结束字符串*/ while(gets(ss))
{
s=ss;
if(s=="") break; sscanf(ss,"%s %s",s1,s2);
m[s2]=s1;//以鼠国语为键值,因为查询时输入的是鼠国语
}
while(gets(ss))
{
s=ss;
it=m.find(s);
if(it != m.end())
cout<<(*it).second<<endl;
else
printf("eh\n");
}
return ;
}

zoj 1109 Language of FatMouse(map映照容器的典型应用)的更多相关文章

  1. zoj 1109 Language of FatMouse(map)

    Language of FatMouse Time Limit: 10 Seconds      Memory Limit: 32768 KB We all know that FatMouse do ...

  2. zoj 1109 Language of FatMouse(字典树)

    Language of FatMouse Time Limit: 10 Seconds      Memory Limit: 32768 KB We all know that FatMouse do ...

  3. ZOJ 1109 Language of FatMouse 【Trie树】

    <题目链接> 题目大意: 刚开始每行输入两个单词,第二个单词存入单词库,并且每行第二个单词映射着对应的第一个单词.然后每行输入一个单词,如果单词库中有相同的单词,则输出它对应的那个单词,否 ...

  4. zoj 1109 Language of FatMouse 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=109 题目意思:给出一个mouse-english词典,问对于输入的m ...

  5. ZOJ 1109 Language of FatMouse

    较简单字典树,每输入一对字符串,前一个放在字典(数组)中,后一个插入字典树中,并将其最终的flag赋为前一个在数组中的下标,再就好找了.输入的处理方法要注意一下. 代码: #include <i ...

  6. zoj 1109 zoj 1109 Language of FatMouse(字典树)

    好开心,手动自己按照字典树的思想用c写了一个优化后的trie字典树,就是用链表来代替26个大小的字符数组.完全按照自己按照自己的想法打的,没有参考如何被人的代码.调试了一天,居然最后错在一个小问题上, ...

  7. zoj 2104 Let the Balloon Rise(map映照容器的应用)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2104 题目描述: Contest time again! Ho ...

  8. C++ map 映照容器

    map映照容器的元素数据是一个键值和一个映照数据组成的,键值与映照数据之间具有一一映照的关系. map映照容器的数据结构是采用红黑树来实现的,插入键值的元素不允许重复,比较函数只对元素的键值进行比较, ...

  9. map映照容器的使用

    map映照容器可以实现各种不同类型数据的对应关系,有着类似学号表的功能. 今天在做并查集的训练时,就用上了map映照容器. 题目就不上了,直接讲一下用法.顺便说一下,实现过程是在C++的条件下. #i ...

随机推荐

  1. 修复msvcp120.dll

    https://www.microsoft.com/zh-CN/download/details.aspx?id=40784

  2. Delphi 与 Word_VBA

    '插入表格Sub setTable()  Set myRange = ActiveDocument.Range(Start:=2, End:=2)  ActiveDocument.Tables.Add ...

  3. 如何让cxgrid既能充满又能根据内容进行宽度调整?

    如何让cxgrid既能充满又能根据内容进行宽度调整? 原创 2009年02月25日 10:10:00 2793 1.选中cxgridview,在属性中找OptionsView--->ColumA ...

  4. ZOJ 1259 Rails

    stack的应用 #include<iostream> #include<cstdio> #include<stack> using namespace std; ...

  5. hdu 1.3.2 Moving Tables

    这道题比较简单,就是用数组存取其路径.如101和102是对门,其过道号可以记为51.  1和2之间的为1. 今早突然收到操作系统停课的通知,哈哈 回来就做一下水题,开心 #include<cst ...

  6. SharePoint 列表中增加列编辑功能菜单

    需求描述 在企业的部署中,经常将SharePoint和TFS集成在一起,两个系统之间相互读取数据,展现开发进度.在TFS 2018之前版本中,由于TFS的门户定制功能有限,用户比较喜欢使用ShareP ...

  7. Linux下可视化空间分析工具ncdu

    场景:磁盘空间占满后快速查找某个目录(子目录)占用空间大. ncdu /var (分析后按左右键查看即可)

  8. 通过键盘控制改变物体transform值

    通过键盘控制改变物体transform值 private Vector3 trans; //使用Rotate绕y 轴旋转 transform.Rotate(new Vector3(0,Input.Ge ...

  9. Android 四大组件之" ContentProvider "

    前言 ContentProvider作为Android的四大组件之一,是属于需要掌握的基础知识,可能在我们的应用中,对于Activity和Service这两个组件用的很常见,了解的也很多,但是对Con ...

  10. Java 泛型通配符

    package com.waston; import java.util.*; public class Main { public static void main(String[] args) { ...