http://acm.hdu.edu.cn/showproblem.php?pid=1075

What Are You Talking About

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

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应用,三但是模拟起来还是很难啊!

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <map> using namespace std; int main()
{
char str1[],str2[],str3[];
map<string ,string >m;
map<string ,string >::iterator it;
scanf("%*s");
while(scanf("%s",str2)!=EOF&&str2[]!='E')
{
scanf("%s",str3);
m[str3]=str2;
}
scanf("%*s");
getchar();
while(cin.getline(str1,)&&str1[]!='E')//遇到换行停止
{
int step=;
memset(str2,'\0',sizeof(str2));
for(int i=;i<strlen(str1);i++)
{
if(str1[i]<'a' || str1[i]>'z')
{
if(step)
{
it=m.find(str2);
if(it != m.end())
{
cout<<it->second;
}
else
{
printf("%s",str2);
}
step=;
memset(str2,'\0',sizeof(str2));
}
cout<<str1[i];
}
else
str2[step++]=str1[i];
}
puts("");
//printf("\n");
}
return ;
}

hdu 1075 (map)的更多相关文章

  1. hdu 1075 map的使用 字符串截取的常用手段 以及string getline 使用起来的注意事项

    首先说字符串的截取套路吧 用坐标一个一个的输入 用遍历的方式逐个去检查字符串中的字符是否为符合的情况 如果是的话 把该字符放入截取string 中 让后坐标前移 如果不是的话 截取结束 坐标初始化 然 ...

  2. HDU 1075 What Are You Talking About(Trie的应用)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  3. HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)

    Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn't know the lan ...

  4. HDU 1075 What Are You Talking About (stl之map映射)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  5. HDU 1075 字符串映射(map)

    Sample InputSTARTfrom fiwohello difhmars riwosfearth fnnvklike fiiwjENDSTARTdifh, i'm fiwo riwosf.i ...

  6. hdu 1075 What Are You Talking About(map)

    题意:单词翻译 思路:map #include<iostream> #include<stdio.h> #include<string.h> #include< ...

  7. hdu 1075 What Are You Talking About(map)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  8. hdu 1075 What Are You Talking About

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意:比较简单,易懂,这里不做说明. 解法:第一种方法:用map映射,耗时1000+ms:第二种 ...

  9. 题解报告:hdu 1075 What Are You Talking About

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 Problem Description Ignatius is so lucky that he ...

随机推荐

  1. UIImageView(转)

    UIImageView,顾名思义,是用来放置图片的.使用Interface Builder设计界面时,当然可以直接将控件拖进去并设置相关属性,这就不说了,这里讲的是用代码. 1.创建一个UIImage ...

  2. Delphi 取得桌面文件夹的路径和取得我的文档的路径

    Uses Windows,Registry; function GetShellFolders(strDir: string): string; const regPath = '\Software\ ...

  3. V4L2应用程序框架-二【转】

    本文转载自:http://blog.csdn.net/tommy_wxie/article/details/11371439 V4L2驱动框架 主设备号: 81 次设备号:    0-63    64 ...

  4. 161110、彻底征服 Spring AOP 之 实战篇

    Spring AOP 实战 看了上面这么多的理论知识, 不知道大家有没有觉得枯燥哈. 不过不要急, 俗话说理论是实践的基础, 对 Spring AOP 有了基本的理论认识后, 我们来看一下下面几个具体 ...

  5. C# Driver LINQ Tutorial

    1.介绍 该教程涵盖了1.8版本的C#驱动中的LINQ查询.你可能已经阅读最新的C# Driver Tutorial. 2.快速开始 首先,给程序添加下面的using声明 using MongoDB. ...

  6. plsql日期乱码

    乱码状况如截图: 控制面板\所有控制面板项\系统\高级系统设置\环境变量, 设置系统变量,变量名:NLS_LANG,变量值:Simplified Chinese_China.AL32UTF8改为SIM ...

  7. Redis的使用完整版

    [Redis基本] 1.redis安装完成后的几个文件: redis-benchmark  性能测试工具(批量写入)./bin/redis-benchmark -n 10000  即可一次性写入100 ...

  8. require()与 require_once()、 include与include_once()

  9. JAVA字段的初始化规律

    JAVA字段的初始化规律 1.类的构造方法 (1)“构造方法”,也称为“构造函数”,当创建一个对象时,它的构造方法会被自动调用.构造方法与类名相同,没有返回值. (2)如果类没有定义构造函数,Java ...

  10. python中string.casefold和string.lower区别

    string.casefold和string.lower 区别 python 3.3 引入了string.casefold 方法,其效果和 string.lower 非常类似,都可以把字符串变成小写, ...