hdoj1075 What Are You Talking About
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
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?
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.
START
#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的更多相关文章
- HDOJ1075字典翻译(map应用)
#include<iostream> #include<cstdio> #include<map> #include<string> #include& ...
随机推荐
- Linux 下搭建流媒体服务器
http://blog.csdn.net/huangtaishuai/article/details/9836581 ----------------------------------------- ...
- oracl 、mysql在线查看文档
Oracle .mysql在线开发文档: http://www.runoob.com/sql/sql-union.html
- 获取html元素的XPath路径
<!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js&qu ...
- MySQL 联合索引测试2
接上一篇文章: http://www.cnblogs.com/xiaoit/p/4430300.html 1:首先删掉上一篇建立的索引,重新建立一个. mysql> DROP INDEX idx ...
- javaWeb 批量下载图片
批量下载网页图片 CreateTime--2017年9月26日15:40:43 Author:Marydon 所用技术:javascript.java 测试浏览器:chrome 开发工具:Ecli ...
- struts2接收参数的几种形式
1.使用属性 HTML: <form action="login" method="post" name="form1"> 用户 ...
- vsftp客户连接常见故障现象
ftp客户连接常见故障现象现象0:> ftp: connect :连接被拒绝原因: 服务没启动解决: # chkconfig vsftpd on<Enter> 现象1:500 OOP ...
- Linux 系统访问控制列表ACL
常见的文件系统的一般权限(rwx).特殊权限(SUID,SGID,STICK).隐藏权限(chattr)其实有个共性——权限是针对某一类用户设置的.而如果希望对某个指定的用户进行单独的权限控制,那么就 ...
- 关联更新SQL语句
update F_A_Info set level=b.level from F_A_Info a,F_A_Info_QUAN b where a.id=b.id
- ZooKeeper做独立server执行(上)
ZooKeeper做独立server执行(上) 作者:chszs.转载需注明.博客主页:http://blog.csdn.net/chszs 一.ZooKeeper安装及配置 版本号:ZooKeepe ...