《ACM程序设计》书中题目--problem b
来源:互联网 发布:程序员技能树 编辑:程序博客网 时间:2024/04/29 03:11
Description
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 ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay
Output for Sample Input
catehloops
解题思路:
运用map容器,将老鼠的语言与人类的语言进行关联,再次输入要翻译的老鼠的语言,在关键字中找到对应项,输出实值(人类语言)即可。
代码:
#include <bits/stdc++.h>using namespace std;int main(){ string a,b,n; map<string,string> m; map<string,string>::iterator p; for(int i=0;i<100005;i++) { cin>>a>>b; m[b]=a; } while(cin>>n) { p=m.find(n); if(p!=m.end()) cout<<p->second<<endl; else cout<<"eh"<<endl; } return 0;}
- 《ACM程序设计》书中题目--problem b
- 《ACM程序设计》书中题目--problem j
- 《ACM程序设计》书中题目--problem o
- 《ACM程序设计》书中题目--problem u
- 《ACM程序设计》书中题目--problem l
- ACM程序设计》书中题目--problem t
- 《ACM程序设计》书中题目--problem k
- 《ACM程序设计》书中题目--problem m
- 《ACM程序设计》书中题目--problem n
- 《ACM程序设计》书中题目--problem r
- 《ACM程序设计》书中题目--problem z
- 《ACM程序设计》书中题目--problem y
- 《ACM程序设计》书中题目--problem w
- 《ACM程序设计》书中题目--problem h
- 《ACM程序设计》书中题目--problem p
- 《ACM程序设计》书中题目--problem x
- 《ACM程序设计》书中题目--problem v
- ACM程序设计 书中题目 B
- MyEclipse2014通过数据库表反向生成映射文件
- 【Bzoj4196】软件包管理器
- Joomla!中的controller
- 合成视频遇见的坑
- 弱密码的危害及账号密码配置要求
- 《ACM程序设计》书中题目--problem b
- 矩阵分解中的损失函数
- Merkle Tree(默克尔树)算法解析
- 图片转换word格式用什么软件好
- iOS定时器三种初始化方式
- iOS 视频音频播放器 文件管理的实现
- CSS3的user-select属性,用来指定文本的可选择性
- 如何将一个Java对象写到文件里
- mysql5.6及以下怎么查询数据库里面json呢