What Are You Talking About

点我

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!

 
一道翻译转换题,学会了map使用。
  1. #include<iostream>
  2. #include<map>
  3. #include<cstdio>
  4. #include<algorithm>
  5. #include<string>
  6. #include<cstring>
  7. using namespace std;
  8. int main()
  9. {
  10. map<string,string>mp;
  11. int i=,j,k;
  12. char s1[],s2[];
  13. char a[];
  14. char ch;
  15. char buf[];
  16. // freopen("in.txt","r",stdin);
  17. gets(a);
  18. while(scanf("%s",s1))
  19. {
  20. if(==strcmp(s1,"END"))
  21. break;
  22. else
  23. {
  24. scanf("%s",s2);
  25. mp[s2]=s1;
  26. }
  27. }
  28. getchar();
  29. gets(a);
  30. while(scanf("%c",&ch)==)
  31. {
  32. if(isalpha(ch))
  33. {
  34. buf[i++]=ch;
  35. }
  36. else
  37. {
  38. buf[i]='\0';
  39. i=;
  40. if(strcmp(buf,"END")==)
  41. break;
  42. if(mp.find(buf)!=mp.end())
  43. cout<<mp[buf];
  44. else
  45. printf("%s",buf);
  46. printf("%c",ch);
  47. }
  48.  
  49. }
  50. return ;
  51. }

翻译题(map使用)的更多相关文章

  1. POJ 1087 最大流裸题 + map

    A Plug for UNIX Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15597   Accepted: 5308 ...

  2. C#LeetCode刷题-Map

    Map篇 # 题名 刷题 通过率 难度 846 一手顺子   33.7% 中等 855 考场就座   20.8% 中等

  3. 百度之星IP聚合(水题map&字符处理)

    虽然题目停水的,但是好像字符处理运用的还比较合适 Problem Description 当今世界,网络已经无处不在了,小度熊由于犯了错误,当上了度度公司的网络管理员,他手上有大量的 IP列表,小度熊 ...

  4. HDOJ1075字典翻译(map应用)

    #include<iostream> #include<cstdio> #include<map> #include<string> #include& ...

  5. codeforces 659C C. Tanya and Toys(水题+map)

    题目链接: C. Tanya and Toys time limit per test 1 second memory limit per test 256 megabytes input stand ...

  6. Gym - 101670H Go Northwest!(CTU Open Contest 2017 思维题+map)

    题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather disco ...

  7. CF 988C Equal Sums 思维 第九题 map

    Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  8. 一道算法题加深我对C++中map函数的理解

    一.一道题目引发我对map函数的考量 首先是题目大意:有n个银行,a[i]表示这个人在第i个银行有a[i]块钱(可以是负数),所有银行的钱加起来正好是0.每次只能在相邻的银行之间转账,问最少要转多少次 ...

  9. 九度OJ 1079:手机键盘 (翻译)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2279 解决:1233 题目描述: 按照手机键盘输入字母的方式,计算所花费的时间 如:a,b,c都在"1"键上,输入a只 ...

随机推荐

  1. 高可用集群(HA)之Keeplived原理+配置过程

    原理--> 通过vrrp协议,定义虚拟路由,在多个服务节点上进行转移. 通过节点优先级,将初始虚拟路由到优先级高的节点上,checker工作进程检测到主节点出问题时,则降低此节点优先级,从而实现 ...

  2. 转:nginx location匹配规则

    location匹配命令 ~      #波浪线表示执行一个正则匹配,区分大小写~*    #表示执行一个正则匹配,不区分大小写^~    #^~表示普通字符匹配,如果该选项匹配,只匹配该选项,不匹配 ...

  3. visual studio 2008安装报错问题处理

    今天刚入职,安装visual studio 2008时报错说web创建组件安装错误,后来发现是因为之前这电脑安装visual studio 2008的时候是office2007刚安装的版本,可是后来系 ...

  4. 设置PlaceHolder的颜色

    input::-webkit-input-placeholder{ color:green; } input::-webkit-input-placeholder { color: #999; } i ...

  5. HTML5 Canvas动画效果演示 - 流浪的鱼 - 博客频道 - CSDN.NET

    HTML5 Canvas动画效果演示 - 流浪的鱼 - 博客频道 - CSDN.NET HTML5 Canvas动画效果演示

  6. iOS 之点击按钮改变状态的图片

    .h  文件中 @property (strong, nonatomic) IBOutletUIButton *publishBtton; @property (strong, nonatomic) ...

  7. Android.mk文件语法规范及使用模板

    Android.mk文件语法详述 介绍:------------这篇文档是用来描述你的C或C++源文件中Android.mk编译文件的语法的,为了理解她们我们需要您先看完docs/OVERVIEW.h ...

  8. 评教数据整理专用VBA小程序

    这次评教的所有数据存放在两个数据库中,比如说给某教师评论的学生有100个,可是结果有40个的数据在数据库A中,另外60人的数据在数据库B中.那么,如何将两个库中的数据整合,最后得到教师的准确成绩成为了 ...

  9. 9年经验,总结SEO职业瓶颈

    昨天与某集团的副总与部门总监沟通了一些关于SEO发展与瓶颈的问题,有很多感触,今天整理出来分享给大家.其实关于SEO瓶颈这个话题已经不是一年两年了,很多新人老人越来越困惑,9年历程一路风雨走来,希望能 ...

  10. 4. Linux 系统目录

    一.Linux 系统目录的作用 /home            用户主目录的根节点,所有用户自己独有的文件一般放在这个目录下的用户目录下 /bin                二进制可执行命令 / ...