您的位置:首页 > 其它

zoj 1109 Language of FatMouse(map)

2017-03-10 10:46 369 查看
LanguageofFatMouseTimeLimit:10SecondsMemoryLimit:32768KB
WeallknowthatFatMousedoesn'tspeakEnglish.ButnowhehastobepreparedsinceournationwilljoinWTOsoon.ThankstoTuringwehavecomputerstohelphim.

InputSpecification

Inputconsistsofupto100,005dictionaryentries,followedbyablankline,followedbyamessageofupto100,005words.EachdictionaryentryisalinecontaininganEnglishword,followedbyaspaceandaFatMouseword.NoFatMousewordappearsmorethanonceinthedictionary.ThemessageisasequenceofwordsinthelanguageofFatMouse,onewordoneachline.Eachwordintheinputisasequenceofatmost10lowercaseletters.

OutputSpecification

OutputisthemessagetranslatedtoEnglish,onewordperline.FatMousewordsnotinthedictionaryshouldbetranslatedas"eh".

SampleInput

dogogday
catatcay
pigigpay
frootootfray
loopsoopslay

atcay
ittenkay
oopslay

OutputforSampleInput

cat
eh
loops
思路:主要应用映照容器map,其次是数据的处理,该如何判断对应完了,而该输出了,这里要根据那个空行判断。所以应该一行一行输入。


#pragmawarning(disable:4786)
#include<iostream>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
usingnamespacestd;
intmain(){
map<string,string>mp;
strings;
charss[100],s1[100],s2[100];
while(gets(ss)){
s=ss;
if(s==""){
break;
}else{
sscanf(s.c_str(),"%s%s",s1,s2);//固定输入源字符串
mp[s2]=s1;
}
}
map<string,string>::iteratorit;
while(gets(ss)){
s=ss;
it=mp.find(s);
if(it!=mp.end())
printf("%s\n",mp[s].c_str());
else
printf("eh\n");
}
return0;
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: