What Are You Talking About

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K (Java/Others)
Total Submission(s): 10226    Accepted Submission(s): 3238

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容器写的嘎嘎 ,写了两天,累死我了,但可喜的是,AC了
 #pragma warning(disable:4786)
#include<iostream>
#include<string>
#include<cstring>
#include<map>
using namespace std;
map<string,string>m;
map< string , string >::iterator it;
void fuu(char a[])
{
it = m.find(a) ; if( it != m.end() )
cout<<it->second;
else cout<<a;
}
void fun(char mm[])
{
char s[];
int i,nn=;
int x=strlen(mm);
for(i=; i<x; i++)
{
if(mm[i]!=' ' && mm[i]>='a' && mm[i]<='z')//把所有字符串中的单词转化成单个的单词,然后再map容器中寻找
{
s[nn++]=mm[i];
if(i==x-)
{
s[nn]='\0';
fuu(s);
cout<<mm[x-];
break;
}
}
else if(mm[i]==' ' || (mm[i]<'a' || mm[i]>'z'))
{
s[nn]='\0';
if(nn>)
fuu(s);
nn=;
cout<<mm[i];
}
}
return ;
}
int main()
{
// freopen("Out.txt","w",stdout);
int len;
char a[],b[],mm[],ch[];
cin>>ch;
while()
{
cin>>a>>b;
len=strlen(a);
if(len== && a[]=='E' && a[]=='N' && a[]=='D')
break;
m[b]=a;
}
int i=;
while()
{
gets(mm);
len=strlen(mm);
if(len== && mm[]=='E' && mm[]=='N' && mm[]=='D')
{
break;
}
fun(mm);
if(i>)
cout<<endl;//格式错了调了一个小时啊,最后才在这加了一个
i++;
}
return ;
}

hdoj1075 What Are You Talking About的更多相关文章

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

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

随机推荐

  1. 亲自己主动手从源代码 构建 Groovy 2.3.8 公布包

    今天为了学习 怎样使用 Groovy 写 Groovy 的測试代码, 所以到 http://groovy.codehaus.org/Download 下载了 Groovy 2.3.8 的源码包. Gr ...

  2. Linq to Entity调用存储过程【转】

    http://www.cnblogs.com/chenxizhang/archive/2010/01/03/1638201.html

  3. 【独立开发人员er Cocos2d-x实战 001】csb文件导出和载入

    使用cocos studio进行资源文件导出: 然后在cocosproject中进行载入csb文件:  auto myLayout = CSLoader::createNode("/res/ ...

  4. idea 配置多个jdk

      1.File -->Project Structure 2.SDKs-->点击+号-->JDK-->目录选择到jdk文件夹所在的位置 3.选择jdk所在路径 4.可以配置多 ...

  5. [Done]Spring @Pointcut 切点调用不到(SpringAOP嵌套方法不起作用) 注意事项

    今天在开发过程中,遇到一个问题卡了很久,测试代码如下: package spring.pointcut; import org.aspectj.lang.ProceedingJoinPoint; im ...

  6. 30、Java中Set集合之HashSet、TreeSet和EnumSet

    Set集合是Collection的子集,Set集合与Collection基本相同,没有提供任何额外的方法,只是Set不允许包含重复的元素. Set集合3个实现类:HashSet.TreeSet.Enu ...

  7. 17、JAVA流程控制

    一.IF 1.第一种形式:if if(逻辑表达式){ 语句1; 语句2; ... } 当if中只有一条语句时,可以省略{} 2.第二种形式:if-else if(逻辑表达式){ 语句块1: } els ...

  8. Eureka集群试验的一点总结

    先简单描述一下试验: 试验在一台机器上进行,假设有host文件中配置了以下内容 127.0.0.1 left 127.0.0.1 center 127.0.0.1 right 试验中搭建三个注册中心实 ...

  9. 微信小程序-简易计算器

    代码地址如下:http://www.demodashi.com/demo/14210.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...

  10. 微信小程序用户数据解密

    概述 通过微信web开发者工具创建登录,获取用户信息,发送至后台,进行用户数据解密 详细 代码下载:http://www.demodashi.com/demo/10705.html 一.准备工作 1. ...