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& ...
随机推荐
- 转:StdRegProv类所属方法的使用
在root\default命名空间中的StdRegProv类(标准注册表提供程序)提供了下面16种方法,我们将陆续介绍这些方法的使用规则,并给出分别用WBscript和Powershell编写的例子. ...
- C#编写Windows服务程序 (服务端),client使用 消息队列 实现淘宝 订单全链路效果
需求: 针对 淘宝提出的 订单全链路 产品接入 .http://open.taobao.com/doc/detail.htm?id=102423&qq-pf-to=pcqq.group oms ...
- java中static、this、super、final用途、用法及实例
一.static 请先看下面这段程序: public class Hello { public static void main(String[] args){ //(1) System.out.pr ...
- 【mysql】Innodb三大特性之adaptive hash index
1.Adaptive Hash Indexes 定义 If a table fits almost entirely in main memory, the fastest way to perfor ...
- 查看Windows端口及端口关闭方法(转)
摘自:http://www.hackbase.com/tech/2011-05-17/63766.html 查看Windows端口及端口关闭方法 一.查看已开放的端口: 1.借助系统自带MS-DOS命 ...
- selenium+python : Waits---study
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.s ...
- OAF_OAF控件系列1 - Region Type汇总(概念)
2014-06-22 Created By BaoXinjian
- Spring +quartz获取ApplicationContext上下文
job存在数据库中,能够进行动态的增增删改查,近期遇到了怎样获取ApplicationContext上下文的问题.解决的方法例如以下 applicationContext-quartz.xml < ...
- Python max() 方法
描述 Python max() 方法返回字符串中最大的字母(26个字母中最大的是Z). 语法 max() 方法语法: max(S) 参数 S -- 字符串. 返回值 返回字符串中最大的字母. 实例 以 ...
- 透析Java本质-谁创建了对象,this是什么
是构造方法创建的对象吗 package com.java.essence_36; import java.util.ArrayList; import java.util.List; /** * Cr ...