POJ 2503 Babelfish
来源:互联网 发布:朝鲜有多穷 知乎 编辑:程序博客网 时间:2024/06/07 02:57
题意:给出单词组,然后询问第二个单词,输出第一个单词。如果单词不存在输出eh;单词组的读入以空行作为结束符。这个读入比较麻烦。
解法:map搞一搞。
#include <iostream>#include <cstring>#include <cstdio>#include <string>#include <map>using namespace std;map <string,string> trans;map <string,bool> yes;int main(){ char s[50]; while(1) { gets(s); if(s[0]=='\0') break; else { char a1[20],a2[20]; int i = 0 ,j = 0; for(j = 0 ; s[i] != ' ' ; j++,i++) { a1[j] = s[i]; } a1[j] = '\0'; i++; for(j = 0 ; i < strlen(s) ; i++,j++) { a2[j] = s[i]; } a2[j] = '\0'; // printf("%s %s",a1,a2); yes[a2] = true; trans[a2] = a1; } } while(scanf("%s",s)!=EOF) { if(yes[s]) cout<<trans[s]<<endl; else cout<<"eh"<<endl; } return 0;}
0 0
- poj 2503 Babelfish
- POJ 2503 Babelfish(HASH)
- poj 2503 Babelfish
- POJ 2503 Babelfish
- POJ 2503 Babelfish
- poj 2503 Babelfish
- POJ 2503 Babelfish
- poj 2503 Babelfish 【hash】
- poj 2503 Babelfish【trie】
- POJ 2503 Babelfish
- poj-2503 Babelfish
- poj-2503 Babelfish
- poj 2503 Babelfish
- poj 2503 Babelfish
- POJ 2503 Babelfish
- POJ 2503 Babelfish (Hash)
- POJ 2503 Babelfish
- poj 2503 Babelfish(二分)
- Ugly Numbers
- HDU 1272 小希的迷宫
- 【翻译自mos文章】Oracle 11gR2 relink 新特性
- Codeforces Round #221 (Div. 2) D. Maximum Submatrix 2 (思维题)
- Linux数据备份Rsync+inotify+crontab+tar(一)
- POJ 2503 Babelfish
- 扫雷游戏 C语言实现
- Java学习笔记9
- 出现次数最多的整数
- POJ 3067 Japan
- test
- Codeforces 514 B . Han Solo and Lazer Gun 精度 除0
- 华容道自动求解 java版
- 【翻译自mos文章】解释 datafile name中的MISSING关键字