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".
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; }
相关文章推荐
- zoj 1109 Language of FatMouse(map映照容器的典型应用)
- ZOJ1109_Language of FatMouse(STL/map)
- UVa 10282 / POJ 2503 Babelfish / ZOJ 1109 Language of FatMouse (STL&map)
- zoj 1109 Language of FatMouse
- ZOJ 1109 Language of FatMouse
- ZOJ Problem Set - 1109 Language of FatMouse
- ZOJ 1109 Language of FatMouse
- ZOJ 1109 Language of FatMouse
- zoj 1109 : Language of FatMouse
- zoj 1109 zoj 1109 Language of FatMouse(字典树)
- ZOJ 1109 Language of FatMouse
- ZOJ Problem Set–1109 Language of FatMouse
- zoj 1109 Language of FatMouse
- zoj 1109 : Language of FatMouse
- ZOJ1109 Language of FatMouse
- 字典树例题介绍:ZOJ 1109 Language of FatMouse,HDOJ 1075hdoj What Are You Talking About
- ZOJ1109 Language of FatMouse
- zoj_1109 Language of FatMouse
- ZOJ 1109 Language of FatMouse (字典树)
- zoj 1109 Language of FatMouse 【字典树】