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. 

map存储字符数组比较麻烦
所以用map存储string 两个string一一对应 只能用cin输入
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include <map>
using namespace std;
int main()
{
map<string,string>mapDic;
string a,b,c;
cin>>c;
while(cin>>a&&a!="END"){
cin>>b;
mapDic[b]=a;
}
cin>>c;
getchar();
char s[];
while(){
gets(s);
if(strcmp(s,"END")==)break;
int n=strlen(s);
b="\0";
for(int i=;i<n;i++){
if(s[i]>='a'&&s[i]<='z')b+=s[i]; //s[i]是字母,就将其存入string b中
else{ //若是s[i]不为字母
if(mapDic[b]!="\0")cout<<mapDic[b]; //就判断b是否可以用map转化地球语言 可以得话输出地球语言
else cout<<b; //不可以直接输出b
b="\0"; //清零b
printf("%c",s[i]); //不为字母 输出字符s[i]
}
}
printf("\n");
}
//system("pause");
return ;
}

T - stl 的mapⅡ的更多相关文章

  1. C++ STL中Map的按Key排序和按Value排序

    map是用来存放<key, value>键值对的数据结构,可以很方便快速的根据key查到相应的value.假如存储学生和其成绩(假定不存在重名,当然可以对重名加以区 分),我们用map来进 ...

  2. STL中map与hash_map的比较

    1. map : C++的STL中map是使用树来做查找算法; 时间复杂度:O(log2N) 2. hash_map : 使用hash表来排列配对,hash表是使用关键字来计算表位置; 时间复杂度:O ...

  3. STL中map,set的基本用法示例

    本文主要是使用了STL中德map和set两个容器,使用了它们本身的一些功能函数(包括迭代器),介绍了它们的基本使用方式,是一个使用熟悉的过程. map的基本使用: #include "std ...

  4. STL中map与hash_map容器的选择收藏

    这篇文章来自我今天碰到的一个问题,一个朋友问我使用map和hash_map的效率问题,虽然我也了解一些,但是我不敢直接告诉朋友,因为我怕我说错了,通过我查询一些帖子,我这里做一个总结!内容分别来自al ...

  5. C++ STL中Map的相关排序操作:按Key排序和按Value排序 - 编程小径 - 博客频道 - CSDN.NET

    C++ STL中Map的相关排序操作:按Key排序和按Value排序 - 编程小径 - 博客频道 - CSDN.NET C++ STL中Map的相关排序操作:按Key排序和按Value排序 分类: C ...

  6. STL之map排序

    描述 STL的map中存储了字符串以及对应出现的次数,请分别根据字符串顺序从小到大排序和出现次数从小到大排序. 部分代码已经给出,请补充完整,提交时请勿包含已经给出的代码. int main() { ...

  7. C++中的STL中map用法详解(转)

    原文地址: https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html C++中的STL中map用法详解   Map是STL的一个关联容器,它提供 ...

  8. C++ STL中Map的按Key排序跟按Value排序

    C++ STL中Map的按Key排序和按Value排序 map是用来存放<key, value>键值对的数据结构,可以很方便快速的根据key查到相应的value.假如存储学生和其成绩(假定 ...

  9. [STL] Implement "map", "set"

    练习热身 Ref: STL中map的数据结构 C++ STL中标准关联容器set, multiset, map, multimap内部采用的就是一种非常高效的平衡检索二叉树:红黑树,也成为RB树(Re ...

  10. stl中map的四种插入方法总结

    stl中map的四种插入方法总结方法一:pair例:map<int, string> mp;mp.insert(pair<int,string>(1,"aaaaa&q ...

随机推荐

  1. 1228.1——计算器(未使用MVC设计模式)

    #import "ViewController.h"typedef enum{    kStausNum,    kStausOperation}kStaus; typedef e ...

  2. Emacs入门快捷键

    打开emacs开始一个程序最基本操作: 1.打开Emacs,执行 $ emacs 2.建立一个新的程序文件. 按C-x C-f 然后在屏幕的底部出现minibuffer,光标提示你输入文件名称, 文件 ...

  3. poj 1177 picture

    题目链接:http://poj.org/problem?id=1177 分析:这道题主要用到了线段树.扫描线以及离散化的相关算法. 离散化 离散化是当数字不多但是范围很大时采用的一种方法,将大区间的数 ...

  4. pubwin2009服务端 修改系统时间方法

      所有操作都是必须的,包括重启. 1.建议操作前全体结账,并交班---不结帐的话, 改完时间会出问题的.2.停止pubwin2009服务端 3.将C:\WINDOWS\system32\driver ...

  5. 超级密码(dfs)

    超级密码233 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total S ...

  6. 自己动手写PHP MVC框架

    自己动手写PHP MVC框架 来自:yuansir-web.com / yuansir@live.cn 代码下载: https://github.com/yuansir/tiny-php-framew ...

  7. Keil C51.uew

    /L15"Keil C51" Line Comment = // Block Comment On = /* Block Comment Off = */ Escape Char ...

  8. HTML常用字符

    显示结果 描述 实体名称 实体编号   空格     < 小于号 < < > 大于号 > > & 和号 & & " 引号 &quo ...

  9. 编译boost python模块遇到的错误:../../libraries/boost_1_44_0/boost/python/detail/wrap_python.hpp:75:24: fatal error: patchlevel.h: No such file or directory

    就是遇到类似标题上面的错误. 原因是没有安装对应python的python-dev依赖,不然编译到boost python模块的时候就会出错. 所以解决方案是sudo apt-get install ...

  10. Fragment销毁时replace和add两个方法的区别

    这个首先从一个bug说起,如图:   我们都知道fragment切换有两种方式: 1. replace方式 transaction.replace(R.id.content, IndexFragmen ...