【POJ】2503 - Babelfish(STL)
来源:互联网 发布:淘宝客 流量劫持 编辑:程序博客网 时间:2024/06/06 07:23
点击打开题目
Babelfish
Time Limit: 3000MS Memory Limit: 65536KTotal Submissions: 40350 Accepted: 17188
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
纯纯的 STL 之string、map 的应用题。
在读入数据方面要注意,我不是很会用C++的输入输出流,方法比较笨。
代码如下:
#include <cstdio>#include <map>#include <string>#include <iostream>#include <algorithm>using namespace std;int main(){map<string,string> dic;string a,b;char t;char temp[22];while (t = getchar()){if (t == '\n')break;a.clear();a += t;scanf ("%s",temp);a += temp;scanf ("%s",temp);b.clear();b += temp;dic[b] = a;getchar();}while (~scanf ("%s",temp)){a.clear();a += temp;if (dic[a] != "")cout << dic[a] << endl;elsecout << "eh" << endl;}return 0;}
0 0
- POJ 2503 - Babelfish(STL)
- 【POJ】2503 - Babelfish(STL)
- poj 2503 Babelfish(STL map写法)
- POJ 2503-Babelfish(STL-map)
- POJ 2503 Babelfish(STL-map)
- POJ 2503 Babelfish(STL、二分、字典树、哈希)
- Poj 2503 Babelfish (Trie / STL / BKDR Hash)
- POJ 2503 Babelfish STL-map容器
- POJ 2503 BABELFISH (HASH)
- POJ 2503 Babelfish(Trie)
- POJ 2503 Babelfish(map)
- poj 2503 Babelfish(字典树或STL水题) 解题报告(百炼2804)
- poj 2503 Babelfish(字典树或着STL)
- poj 2503 Babelfish (map,trie 树)
- POJ 2503 Babelfish(二分查找)
- poj 2503 Babelfish(trie树)
- POJ 2503 Babelfish(字典树水题)
- POJ 2503 Babelfish(字典树)
- HDU 5738 Eureka(组合数学)
- C#高级编程之C#语言
- gmt_offset变量是干什么的
- HDU 5755 Gambler Bo(高斯消元解同余方程)
- 字符数字之间的转换
- 【POJ】2503 - Babelfish(STL)
- time wait
- tablayout
- Matlab 和 C++混合编程
- Leetcode 54. Spiral Matrix (Medium) (cpp)
- 用户级线程和内核级线程
- 【Window程序设计:第五版】翻译勘误 转载
- 算法竞赛入门经典(第二版)-刘汝佳-第四章 发放救济金
- Unknown character set: 'utf8mb4' bug解决