poj_2503(map映射)
来源:互联网 发布:淘宝贝亲奶瓶正品 编辑:程序博客网 时间:2024/06/09 21:05
题目链接poj2503
Babelfish
Time Limit: 3000MS Memory Limit: 65536KTotal Submissions: 38820 Accepted: 16578
Description
You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.
Input
Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".
Sample Input
dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay
Sample Output
catehloops
Hint
Huge input and output,scanf and printf are recommended.
Source
Waterloo local 2001.09.22
/*题目大意:给定一系列外国单词,都对应着英语单词。然后给一个外国单词,要求输出相对应的英语单词。若不存在则输出eh 算法分析:可以根据map的映射关系 */ #include <iostream>#include <map>#include <string>#include <cstring>#include <cstdlib>#include <cstdio>using namespace std;int main() {map <string, bool> appear;//记录单词是否出现 map <string , string > p;//单词映射 char t;while (true) {char english[20];char t;//临时字符 t = getchar();if (t == '\n')break;//如果是换行符,跳出 int i = 1;english[0] = t;while (true) {t = getchar();if (t == ' ') {english[i] = '\0';break;}elseenglish[i++] = t;}string forign;cin >> forign;getchar();//吃掉换行符 appear[forign] = true;p[forign] = english;}string word;while (cin >> word) {if (appear[word]) cout << p[word] << endl;elsecout << "eh" << endl;}return 0;}
0 0
- poj_2503(map映射)
- poj_2503
- [解题报告]POJ_2503 字典树,MAP
- poj_2503 哈希
- 映射map
- Map----映射
- map 映射
- map映射
- POJ_2503(基本Hash)
- POJ_2503 Babelfish解题报告.
- map[映射]转
- Hibernate集合映射---Map
- Hibernate Map集合映射
- MAP映射问题
- Hibernate Map映射文件
- 存储器映射 Memory Map
- Map一对多映射!
- VIM键盘映射 (Map)
- AndroidEventBus源码分析
- 分页+新建+跳转+最后页
- Spring mvc 配置详解
- poj 1743 Musical Theme 【后缀数组 最长不重叠重复子串】
- HYSBZ 3196Tyvj 1730 二逼平衡树(树套树)
- poj_2503(map映射)
- HTML音频
- 动态分配内存和链表
- javaEE
- 最长上升子序列
- Scala之模式匹配(Patterns Matching)
- UVa 12096 - The SetStack Computer
- 最长公共子序列 LCS(模板) poj 1458
- javabean总结