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. 【教程】HTML5+JavaScript编写flappy bird

         作者: 风小锐      新浪微博ID:永远de风小锐      QQ:547953539      转载请注明出处 PS:新修复了两个bug,已下载代码的同学请查看一下 大学立即要毕业了. ...

  2. Menubar

    A menubar is a common part of a GUI application. It is a group of commands located in various menus. ...

  3. 在VC中创建DLL文件的方法步骤

    一.Win32动态链接库 1.制作的步骤: (1)新建WIN32 Dynamic-link Library工程,工程名为MyDll,选择A simple DLL project类型. (2)MyDll ...

  4. python之模块csv之CSV文件的写入(基本结构)

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #CSV文件的写入(基本结构) import csv #csv文件,是一种常用的文本格式,用以存储表格数据,很 ...

  5. 【转】ubuntu如何修改/添加/删除硬盘分区的挂载(点)?

    我(macroliu)的问题:安装ubuntu时,/home单独挂载在一个分区,此后我想调整分区大小,删除了/home对应的分区以及另外几个分区,导致开机时找不到挂载点.把硬盘空闲空间分好区后,想把1 ...

  6. JavaScript 中定义变量时有无var声明的区别

    关于JavaScript中定义变量时有无var声明的区别 var a=5; //正确 a=5; //正确 在javascript中,以上两种方法都是定义变量的正确方法.微软的Script56.CHM中 ...

  7. 【LeetCode】41. First Missing Positive (3 solutions)

    First Missing Positive Given an unsorted integer array, find the first missing positive integer. For ...

  8. capacity <<= 1

    import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.prefs.B ...

  9. Eclipse折叠代码 coffee bytes code folding

    提供一个插件下载地址,博客园的: http://files.cnblogs.com/wucg/com.cb.eclipse.folding_1.0.6.jar.zip  将下载的zip文件解压出来的j ...

  10. java JAXB + STAX(是一种针对XML的流式拉分析API)读取xml

    JDK1.5需要添加jar包,1.6以后就不需要了<dependency> <groupId>stax</groupId> <artifactId>st ...