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. Saving HDU hdu

    话说上回讲到海东集团面临内外交困.公司的元老也仅仅剩下XHD夫妇二人了.显然.作为多年拼搏的商人,XHD不会坐以待毙的. 一天,当他正在苦思冥想解困良策的时候.突然想到了自己的传家宝,那是公司成立的时 ...

  2. wtforms的简单示例

    1.先定义一个类: #!/usr/bin/env python # -*- coding: utf-8 -*- # Created by xxx on 2017/3/13 from wtforms i ...

  3. poj 食物链

    比基础的并查集有些进步. 在以下这个链接中有详解: http://blog.csdn.net/ditian1027/article/details/20804911 对于每两个动物的关系,都是先推与终 ...

  4. C语言:用字符读取流和输出流来读写入数据。(文本文件)

    /* 文件的几种操作模式: r:只读   w:只写   rw:可读可写 文件的分类: t:文本文件(字符文件)   b:二进制文件(字节文件) 注意: 采用只读方式打开文件时,如果源文件不存在,打开文 ...

  5. IOS 实现界面本地化(国际化)

    在制作应用程序的时候,可以使用本地化功能,将应用程序的内容翻译成多种语言,在不同的区域显示不同的语言.下面就通过简体中文本地化设置来讲解一下本地化的简单使用. 一.让应用程序支持中文语言环境 选择需要 ...

  6. Android之属性动画(二)

    上一篇文章(链接:http://www.cnblogs.com/jerehedu/p/4458928.html  ),我们对属性动画有了简单的认识,并实际动手使用ObjectAnimator.Anim ...

  7. Cognos访问权限之让拒绝更友善

    关于cognos的访问权限之前我也做了不少总结,但是由于时间关系加上用户也只要实现功能就好,我们做的效果就是像很多人一样,就那样就好了.但是有很多事情,只要你肯动脑筋,你会发现,你还可以做的更好,下面 ...

  8. 解决Sublime包管理package control 报错 There are no packages available for installation

    解决Sublime包管理package control 报错 There are no packages available for installation 真的是哔了狗了,要不是我机智的重新安装了 ...

  9. Drupal Working with nodes, content types and fields

    一个大概的总结,便于对接下来的学习进行理解和运行 在使用Drupal过程中.站点中的内容的不论什么一个部分都是一个节点(node),而每一个节点中又包括了一些默认的字段(fields). 值得说明的是 ...

  10. android中的数据库操作(SQLite)

    android中的数据库操作 android中的应用开发很难避免不去使用数据库,这次就和大家聊聊android中的数据库操作. 一.android内的数据库的基础知识介绍 1.用了什么数据库   an ...