【处理空格】poj2503——Babelfish
2013-08-10 10:31
316 查看
题目:点击打开链接
很水的一道题,但是处理两行之间的空格花了许多功夫,最后还是用了char,因为可以自由修改,相比string需要用insert函数,更加灵活一些。也可以用hash来做,不过有些麻烦就是了。
很水的一道题,但是处理两行之间的空格花了许多功夫,最后还是用了char,因为可以自由修改,相比string需要用insert函数,更加灵活一些。也可以用hash来做,不过有些麻烦就是了。
#include <iostream> #include <string> #include <map> #include <cstdio> using namespace std; int main() { char d1[50],d2[50]; string tp; map<string,string> dic; int count=0; while(1) { char t=getchar(); if(t=='\n') break; else { d1[0]=t; int i=1; while(1) { t=getchar(); if(t==' ') { d1[i]='\0'; break; } else d1[i++]=t; } } cin>>d2; getchar(); //吃掉 输入foreign后的 回车符 dic[d2]=d1; count++; } string tar; while(cin>>tar) { map<string,string>::iterator p=dic.find(tar); if(p==dic.end()) cout<<"eh"<<endl; else cout<<(*p).second<<endl; } return 0; }
相关文章推荐
- Poj 2503 Babelfish(map+串的处理)
- Babelfish(poj2503字符串处理)
- poj 2503 Babelfish
- poj-2503-Babelfish-字典树orMAP or 字符串哈希
- POJ 2503 Babelfish(字典树)
- POJ 2503 - Babelfish(字典树)
- poj 2503 Babelfish
- POJ 刷题系列:2503. Babelfish
- POJ 2503 Babelfish
- POJ 2503 Babelfish ,map
- poj-2503-Babelfish
- POJ 2503 Babelfish
- poj-2503 Babelfish
- poj 2503 Babelfish(字典树)
- POJ 2503 Babelfish[字典树]
- POJ2503 Babelfish(二分)
- poj 2503 Babelfish(二分)
- POJ2503-Babelfish
- POJ - 2503 - Babelfish(字典树)
- POJ 2503 Babelfish