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. 使用 TFDConnection 的 pooled 连接池

    从开始看到这个属性,就一直认为他可以提供一个连接池管理功能, 苦于文档资料太少, 甚至在帮助中对该属性的使用都没有任何介绍,如果你搜索百度,也会发现基本没资料. 最后终于在其官方网站看到了其完整相关的 ...

  2. linux设备驱动归纳总结(三):1.字符型设备之设备申请【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-59416.html linux设备驱动归纳总结(三):1.字符型设备之设备申请 操作系统:Ubunru ...

  3. iOS中 视频直播功能-流媒体的使用(详解)韩俊强的CSDN博客

    上一篇博客:(流媒体实现视频播放和下载功能):http://blog.csdn.net/qq_31810357/article/details/50574914 最近视频直播功能比较火,处于需求,研究 ...

  4. NSData NSDate NSString NSArray NSDictionary 相互转换

    // NSData NSDate NSString NSArray NSDictionary json NSString *string = @"hello word"; NSDa ...

  5. ACM题目————数素数

    令Pi表示第i个素数.现任给两个正整数M <= N <= 104,请输出PM到PN的所有素数. 输入格式: 输入在一行中给出M和N,其间以空格分隔. 输出格式: 输出从PM到PN的所有素数 ...

  6. Mysql-学习笔记(==》事件 十二)

    事件 计划任务(定期定时执行) -- 查看当前mysql数据库是否开启时间功能,默认关闭SHOW VARIABLES LIKE 'event_scheduler'; -- event_schedule ...

  7. Ios中时间无法响应

    今天,开发过程中发现有个button,出现一个很奇怪的现象,只能部分响应事件.多方询问,搜索之后,使用各种方案进行解决,都不好使. 通过将父级视图给增加底色,发现那个按钮部分已经在父级视图之外了.将按 ...

  8. config文件 反射方法

     string testPropertyName = "MainFormText"; Properties.Settings setting = Properties.Settin ...

  9. flume ng之组件介绍

    1.channel 2.source 3.sink 4.直接读取文件Source,有哪两种方式? 5.Channel有几种方式? 6.Sink在设置存储数据时,数据较多,较少的情况下,该如何处理? F ...

  10. Redis基础

    Redis是开源的,支持网络.可基于内存也可持久化的key-value数据库,支持主从复制,读写分离,支持5种基本数据类型,高并发性能 安装redis数据库 下载:http://redis.io/do ...