暑假集训第三周 STL R - What Are You Talking About
来源:互联网 发布:plc编程难吗 编辑:程序博客网 时间:2024/06/10 10:02
R - What Are You Talking About
Time Limit:5000MS Memory Limit:204800KB 64bit IO Format:%I64d & %I64uDescription
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!
知识都是我们应该会的知识,只是还没有学好,没能熟练使用
b+=ch[i];字符串也是可以这样去加的,也可以直接和字符串去比,但数组需要用比较函数
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
#include <iostream>#include <algorithm>#include <map>#include <cstdio>#include <string>#include <string.h>using namespace std;int main(){ string a,b; map<string,string> mp; cin>>a; while(cin>>a&&a!="END") { cin>>b; mp[b]=a; } cin>>a; char ch[3005]; getchar(); while( gets(ch)) { int i,len; if(strcmp(ch, "END") == 0) break; len=strlen(ch); b=""; for(i=0; i<len; ++i) { if(ch[i]<'a'||ch[i]>'z') { if(mp[b]!="") cout<<mp[b]; else cout<<b; b=""; cout<<ch[i]; } else b+=ch[i]; } printf("\n"); } return 0;}
0 0
- 暑假集训第三周 STL R - What Are You Talking About
- STL-map--what are you talking about
- HDU1075 What Are You Talking About 【STL】
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- What Are You Talking About
- 【hdu】 What Are You Talking About (水题 STL)
- HDOJ 1075 -- What Are You Talking About Trie( STL )
- HDU-1075 What Are You Talking About (STL:map)
- 服务器升级linux内核
- hdu 2082 找单词(母函数)
- 黑马程序员-----C语言学习之通讯录应用的代码实现
- ny1055
- 存储过程操作
- 暑假集训第三周 STL R - What Are You Talking About
- Python 之 h5py 读取 matlab 中 .mat 文件 cell 方法浅析
- instancetype 与 id for Objective-C
- 全局变量,static ,extern(cp:http://blog.csdn.net/it_youhun/article/details/8526147)
- 黑马程序员------OC 面向对象和面向过程思想(基础)
- Pinyin4j的基本用法
- 一些前端的心得体会,笔记
- Spring的Bean的生命周期
- C++中指针和引用的区别与联系