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使用。
 #include<iostream>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{
map<string,string>mp;
int i=,j,k;
char s1[],s2[];
char a[];
char ch;
char buf[];
// freopen("in.txt","r",stdin);
gets(a);
while(scanf("%s",s1))
{
if(==strcmp(s1,"END"))
break;
else
{
scanf("%s",s2);
mp[s2]=s1;
}
}
getchar();
gets(a);
while(scanf("%c",&ch)==)
{
if(isalpha(ch))
{
buf[i++]=ch;
}
else
{
buf[i]='\0';
i=;
if(strcmp(buf,"END")==)
break;
if(mp.find(buf)!=mp.end())
cout<<mp[buf];
else
printf("%s",buf);
printf("%c",ch);
} }
return ;
}

翻译题(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. 解决MYSQL弃用模块错误Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future

    今天使用了mysql 5.5版本,就出现了错误.错误提示如下: Deprecated: mysql_connect(): The mysql extension is deprecated and w ...

  2. [TYVJ] P1044 数字三角形

    数字三角形 背景 Background 09年 USACO 11月月赛  铜牌第一道   描述 Description 示出了一个数字三角形. 请编一个程序计算从顶至底的某处的一条路径,使该路径所经过 ...

  3. A Distributed Multichannel MAC Protocol for Multihop Cognitive Radio Networks

    2010 这个呢,就是time slotted的DSA网络MAC层协议. 跟上一篇单纯的Multi Channel实现类似,不过这里是CR网络,因为多了嗅探等操作. 简单的说,time slotted ...

  4. android style="@[package:]style/style_name" ----------styles.xml

    android.widget ----XML attribute |____style="@[package:]style/style_name"

  5. 扩展ArcGIS API for Silverlight/WPF 中的TextSymbol支持角度标注

    原文 http://blog.csdn.net/esricd/article/details/7587136 在ArcGIS API for Silverlight/WPF中原版的TextSymbol ...

  6. web前端设计:JQuery MINI UI

    JQuery MINIUI 个人感觉用起来很爽,所以在此记录之,以后开发过程可能作为备选项.它能缩短开发时间,减少代码量,使开发者更专注于业务和服务端,轻松实现界面开发,带来绝佳的用户体验.在线下载地 ...

  7. UESTC_Frozen Rose-Heads CDOJ 791

    The winter is coming and all the experts are warning that it will be the coldest one in the last hun ...

  8. php header调试,yii2打log

    1  通过header来强制刷新view:在页面最开始添加 <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); h ...

  9. SQL Server2005使用CTE实现递归

    本文来自:http://www.cnblogs.com/wenjl520/archive/2010/01/18/1650393.html CTE递归原理: 递归CTE是由两个最小查询构建的.第一个是定 ...

  10. JVM工作原理和特点(一些二逼的逼神面试官会问的问题)

    作为一种阅读的方式了解下jvm的工作原理 ps:(一些二逼的逼神面试官会问的问题) JVM工作原理和特点主要是指操作系统装入JVM是通过jdk中Java.exe来完毕,通过以下4步来完毕JVM环境. ...