HDU 1075-What Are You Talking About(字符串)
来源:互联网 发布:网络金融产品都有哪些 编辑:程序博客网 时间:2024/06/11 19:29
address :http://acm.hdu.edu.cn/showproblem.php?pid=1075
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.
[/hint]
code:
#include <iostream>#include <string.h>#include <cstdio>#include <map>using namespace std;int main(){ string a,b,c,m; char d[1000]; int i,j,k; int n; map<string,string>ds; cin>>a; while (cin>>b&&b!="END") { cin>>c; ds[c] = b; } cin>>a; getchar(); while (1) { gets(d); if (strcmp(d,"END")==0) break; n = strlen(d); m=""; for (i=0;i<n;i++) { if (d[i]<'a'||d[i]>'z') { if (ds[m]!="") cout<<ds[m]; else cout<<m; m=""; cout<<d[i]; } else m += d[i]; } cout<<endl; } return 0;}
- HDU 1075 What Are You Talking About(map+字符串)
- HDU 1075What Are You Talking About (字符串处理)
- HDU 1075 What Are You Talking About // 字符串映射,Trie
- 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 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 1075 What Are You Talking About
- 怎样教你牢记17个的Win7快捷键!
- Dungeon Master(BFS)
- 51nod 1091 线段的重叠
- Ubuntu 16.04 下部署Node.js+MySQL微信小程序商城
- C#的抽象类和接口的区别
- HDU 1075-What Are You Talking About(字符串)
- 在无重复数字的循环数组中查找给定数返回其下标
- 多态与强制类型转换
- 【JavaSE学习笔记】IO流04_编码、字符输出流Writer、字符输入流Reader、字符转换输入流、字符转换输出流
- IOC以及Spring注入
- ssm分布式框架电商项目(三)
- RESTful API 背后的哲学思想
- text
- Nefu 118 n!后面有多少个0【算术基本定理应用】n!素因子幂次