博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
T - stl 的mapⅡ
阅读量:6326 次
发布时间:2019-06-22

本文共 2359 字,大约阅读时间需要 7 分钟。

Description

Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book into English. Can you help him?        
                

Input

The problem has only one test case, the test case consists of two parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should be ignored, then some lines follow, each line contains two strings, the first one is a word in English, the second one is the corresponding word in Martian's language. A line with a single string "END" indicates the end of the directory part, and this string should be ignored. The book part starts with a single line contains a string "START", this string should be ignored, then an article written in Martian's language. You should translate the article into English with the dictionary. If you find the word in the dictionary you should translate it and write the new word into your translation, if you can't find the word in the dictionary you do not have to translate it, and just copy the old word to your translation. Space(' '), tab('\t'), enter('\n') and all the punctuation should not be translated. A line with a single string "END" indicates the end of the book part, and that's also the end of the input. All the words are in the lowercase, and each word will contain at most 10 characters, and each line will contain at most 3000 characters.        
                

Output

In this problem, you have to output the translation of the history book.        
                

Sample Input

START
from
fiwo hello
difh mars
riwosf earth
fnnvk like
fiiwj
END
START
difh, i'm fiwo riwosf.
i fiiwj fnnvk! END
                

Sample Output

hello, i'm from mars.
i like earth!

Hint

Huge input, scanf is recommended. map存储字符数组比较麻烦 所以用map存储string  两个string一一对应 只能用cin输入
#include
#include
#include
#include
#include
using namespace std;int main() { map
mapDic; string a,b,c; cin>>c; while(cin>>a&&a!="END"){ cin>>b; mapDic[b]=a; } cin>>c; getchar(); char s[3005]; while(1){ gets(s); if(strcmp(s,"END")==0)break; int n=strlen(s); b="\0"; for(int i=0;i
='a'&&s[i]<='z')b+=s[i]; //s[i]是字母,就将其存入string b中 else{ //若是s[i]不为字母 if(mapDic[b]!="\0")cout<

 

 

 

转载地址:http://xigaa.baihongyu.com/

你可能感兴趣的文章
Linux 内存机制
查看>>
linux下定时任务
查看>>
SharePoint 2013 部署 Part 1
查看>>
DWGSee看图纸dwg文件阅读器免费下载地址
查看>>
高能天气——团队Scrum冲刺阶段-Day 1-领航
查看>>
ISI CVPR journal ranking
查看>>
free movie
查看>>
列表组
查看>>
CF 988E Divisibility by 25 思维 第十二
查看>>
Linux Shell多命令执行
查看>>
Java中的异常处理:何时抛出异常,何时捕获异常,何时处理异常?
查看>>
css3中的变形(transform)、过渡(transtion)、动画(animation)
查看>>
tomcat生产环境JDK部署及虚拟主机等常用配置详解
查看>>
web服务器tomcat入门实战
查看>>
AVEVA CSG 几何图形输出接口
查看>>
POJ 2653 Pick-up sticks(几何)
查看>>
【阶段试题分析】阶段一试题总结
查看>>
Python 模块调用
查看>>
HBase篇--HBase常用优化
查看>>
CMarkUp介绍
查看>>