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. Mongodb 笔记07 分片、配置分片、选择片键、分片管理

    分片 1. 分片(sharding)是指将数据拆分,将其分散存放在不同的机器上的过程.有时也用分区(partitioning)来表示这个概念.将数据分散到不同的机器上,不需要功能强大的大型计算机就可以 ...

  2. java总结第四次//常用类

    六.常用类 主要内容:Object类.String类.Date类.封装类 (一)Object类 1.Object类是所有Java类的根父类 2.如果在类的声明中未使用extends关键字指明其父类,则 ...

  3. 怎样使用AutoLayOut为UIScrollView添加约束

    1.在ViewController中拖入1个UIScrollView,并为其添加约束 约束为上下左右四边与superview对齐 2.在scrollview中,拖入1个UIView,为了便于区分将其设 ...

  4. 【JQGRID DOCUMENTATION】.学习笔记.3.Pager

    处理大量数据时,一次只想显示一小部分.这时就需要Navigation Bar.目前Pager不能用于TreeGrid. 定义 }); 定义高度grid,pager是grid的一部分,宽度等于gird的 ...

  5. 查看mysql的状态

    实时查看mysql状态连接数 查询数 etc mysqladmin  -uroot  -p '' -h status -i 1

  6. xtjh

    <div onkeydown="javascript:if(event.keyCode==13) search()"> <br > ISBN<span ...

  7. 将turnserver设定成开机启动

    1.创建一个文件,在目录/etc/init/下面 #sudo vim /etc/init/turnserver.conf 2.添加如下内容 description "turn server& ...

  8. 【转】MYSQL入门学习之十:视图的基本操作

    转载地址:http://www.2cto.com/database/201212/176775.html 一.视图的基本介绍  www.2cto.com           视图是虚拟的表.与包含数据 ...

  9. c# 服务端

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. extjs 中动态给gridpanel 复选框赋值

    最近在搞extjs时需要动态根据数据给gridpanel的复选框赋值 网上看了很多 ,多不行,最后找到一个好使的方法 如下: RBACformPanel.getSelectionModel().sel ...