What Are You Talking About

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others) Total Submission(s): 10963    Accepted Submission(s): 3521

Problem 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.

 
Author
Ignatius.L
 
  map 容器的应用....map[aa]=bb;
  STL;
代码:
 #pragma warning (disable:4786)
#include<iostream>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
const int maxn =;
char aa[maxn+],bb[];
int main()
{
scanf("%*s");
map<string,string>msg;
while(scanf("%s",aa),strcmp(aa,"END"))
{
scanf("%s",bb);
msg[bb]=aa;
}
scanf("%*s");
getchar();
map<string,string>::iterator it;
memset(bb,'\0',sizeof(bb));
while(cin.getline(aa,),strcmp(aa,"END"))
{
int step=;
for(int i=;i<strlen(aa);i++)
{
if((aa[i]<'a'||aa[i]>'z'))
{
if(step)
{
it=msg.find(bb);
if(it!=msg.end())
{
cout<<(*it).second;
}
else
printf("%s",bb);
step=;
memset(bb,'\0',sizeof(bb));
}
cout<<aa[i];
}
else
{
bb[step++]=aa[i];
}
}
puts("");
}
return ;
}

HDUOJ---What Are You Talking About的更多相关文章

  1. iOS堆栈-内存-代码在据算机中的运行

    其实作程序不管是那行,学什么语言最终的目的是和就算机打交道的,我们写的程序计算机是怎么处理的呢??? 计算机运行我们的程序无非就是吧磁盘-内存-cpu三者结合起来 我们写一个程序代码肯定是在此盘中存着 ...

  2. react native-调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错

    调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错,而在iOS上运行没问题.原因是因为接口是有验证信息的,而调用这个插件时没有传入,在iOS上会自动加 ...

  3. DSAPI多功能组件编程应用-参考-Win32API常数

    DSAPI多功能组件编程应用-参考-Win32API常数 在编程过程中,常常需要使用Win32API来实现一些特定功能,而Win32API又往往需要使用一些API常数,百度搜索常数值,查手册,也就成了 ...

  4. linux源码分析(四)-start_kernel-cgroup

    前置:这里使用的linux版本是4.8,x86体系. cgroup_init_early(); 聊这个函数就需要先了解cgroup. cgroup概念 这个函数就是初始化cgroup所需要的参数的.c ...

  5. iOS开发 - OC - duplicate symbol _OBJC / undefind symbol 错误的相关处理

    前言: 作为一个iOS开发,相信大家都会遇到类似于 “duplicate symbol” 的程序报错. 对于很多新手来说,可能会有点手足无措,因为这种类型的报错一般并非是代码的逻辑错误,大部分情况下是 ...

  6. 泛函编程(10)-异常处理-Either

    上节我们介绍了新的数据类型Option:一个专门对付异常情况出现时可以有一致反应所使用的数据类型.Option可以使编程人员不必理会出现异常后应该如何处理结果,他只是获得了一个None值,但这个Non ...

  7. 14.Object-C--浅谈Foundation框架字符串NSString 与NSMutableString

    OC的字符串时经常使用到的,今天我对于OC字符串做一个简单的总结,如果有错误之处,麻烦留言指正.感谢! NSString是一个不可变长度的字符串对象.表示它初始化以后,你不能改变该变量所分配的内存中的 ...

  8. ios专题 - CocoaPods - 初次体验

    [原创]http://www.cnblogs.com/luoguoqiang1985 这CocoaPods怎么用呢? 参考官方文章:guides.cocoapods.org/using/using-c ...

  9. iso-开发基础知识-1-程序流程

    main-应用程序委托-视图控制器 main()---主函数 应用程序委托  ---AppDelegate     视图控制器 ---ViewController - (BOOL)applicatio ...

  10. mac在变化mysql-rootpassword-各种解决问题的能力

    官方数据:http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix 另值 ...

随机推荐

  1. cas4.0 session中返回更多的用户信息

    实现思路: 新增AccoutAttributeDao类继承StubPersonAttributeDao,重写getPerson方法.实际应用中我们只需要修改getPersion方法中的内容,根据实际情 ...

  2. PHP语言基础之MySql 05 By ACReaper

    PHP的基本语法学完后,我们马上学下PHP如何和MySql进行交互.PHP和MySql进行交互的API可以分为两类,一类是面向过程的,一类是面向对象的,面向对象的我们等复习完面向对象再介绍,现在先介绍 ...

  3. after the first ten days

    This is the first week for me to speak English formally. There’re two main problems: First, I’m scar ...

  4. Linq编程小趣味爱因斯坦谜题

    最近看到一个比较老的题目,题目----在一条街上,有5座房子,喷了5种颜色,每个房里住着不同国籍的人,每个人喝不同的饮料,抽不同品牌的香烟,养不同的宠物,问题---谁养鱼? 以前没事还做过这个题,现在 ...

  5. JavaScript的js文件压缩和格式化工具

    JavaScriptcompressor.com这个网站可是大名鼎鼎啊.以前在找到过压缩 Javascript 代码的程序,一直在用,感觉效果不错.域名是: http://javascriptcomp ...

  6. vue组件级路由钩子函数介绍,及实际应用

    正如其名,vue-router 提供的导航钩子主要用来拦截导航,让它完成跳转或取消. 有多种方式可以在路由导航发生时执行钩子:全局的.单个路由独享的.或者组件级的. 一.全局钩子 你可以使用 rout ...

  7. 日程管理app

    背景: 普通的笔记本显然具有保存占用较大空间的弊端.而笔记类app又借助于虚拟按键输入,便利度稍逊.假设使用电脑,又产生了较大空间的弊端. 手段: 成熟的书写识别技术 方法: 一.专有的划分有制定格子 ...

  8. js移除Array中指定元素

    首先需要找到元素的下标: var array = [2, 5, 9]; var index = array.indexOf(5); 使用splice函数进行移除: if (index > -1) ...

  9. Cognos审核模块的导入与设置

    Cognos审核模块:就是指针对Cognos在运行过程中的对象被执行和访问的日志记录做了一个对象包,在该包里面我们可以从报表里面看到一些日志记录.以方便我们对Cognos的执行记录进行查看,下面我来说 ...

  10. 正则 js截取时间

    项目中要把时间截取,只要年月日,不要时分秒,于是 /\d{4}-\d{1,2}-\d{1,2}/g.exec("2012-6-18 00:00:00") 或者另一种 var dat ...