【hdu】 What Are You Talking About (水题 STL)
来源:互联网 发布:js获取class元素 编辑:程序博客网 时间:2024/06/09 13:52
What Are You Talking About
Time Limit : 10000/5000ms (Java/Other) Memory Limit : 102400/204800K (Java/Other)
Total Submission(s) : 2 Accepted Submission(s) : 2
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
STARTfrom fiwohello difhmars riwosfearth fnnvklike fiiwjENDSTARTdifh, i'm fiwo riwosf.i fiiwj fnnvk!END
Sample Output
hello, i'm from mars.i like earth!HintHuge input, scanf is recommended.
题目太水。。。。。stl 做的
一开始把怎么判断mp的键值是否存在弄忘了。
现在加深印象了
map<string,string>::iterator it=mp.find(str);
if(it==mp.end())则表示不存在
#include<cstdio>#include<string>#include<iostream>#include<map>#include<sstream>#include<cctype>using namespace std; int main(){ string s,w1,w2,line,word; map<string,string> mp; cin>>s; while(cin>>w1&&w1!="END") { cin>>w2; mp[w2]=w1; } cin>>s; getchar(); while(getline(cin,line)&&line!="END") { string str=""; for(int i=0;i<line.length();i++) { if(!isalpha(line[i]) ) { map<string,string>::iterator it=mp.find(str); if(it==mp.end()){cout<<str;} else cout<<mp[str]; str=""; cout<<line[i]; } else str+=line[i]; } cout<<endl; } return 0;}
- 【hdu】 What Are You Talking About (水题 STL)
- HDU-1075 What Are You Talking About (STL:map)
- HDU 1075:What Are You Talking About【字典树 & STL】
- hdu 1075 What Are You Talking About STL的使用
- STL-map--what are you talking about
- HDU1075 What Are You Talking About 【STL】
- hdu 1075 What Are You Talking About
- HDU 1075 What Are You Talking About
- HDU 1075 What Are You Talking About
- HDU-1075 What Are You Talking About
- hdu 1075 What Are You Talking About
- hdu 1075 What Are You Talking About
- hdu 1075 What Are You Talking About
- HDU What Are You Talking About
- HDU-1075-What Are You Talking About
- HDU 1075 What Are You Talking About
- HDU 1075 What Are You Talking About
- hdu 1075 What Are You Talking About
- 打印系统属性System.getProperties()
- hash_map
- thinkphp登陆
- 初学Android,使用自定义的XML资源(十八)
- oracle 千万级别同一数据库 不同scheme下的数据导入
- 【hdu】 What Are You Talking About (水题 STL)
- poj 2352 Stars (树状数组)
- 漂浮的移动广告 碰到边框改变移动路径
- 图像缩放函数
- J2SE基础夯实系列之静态导入,foreach循环,可变参数
- SharePoint2010 Feature功能开发——为SharePoint的ECB菜单(列表项或文档的操作菜单项)添加自定义菜单栏项目
- 三大框架SSH(struts2+spring+hibernate)整合时相关配置文件的模板
- Permission denied: make_sock: could not bind to address处理
- 我不知道怎么加图片了···