poj 2503_Babelfish_map
2016-12-15 20:53
302 查看
题目大意
在一堆字符串中找到匹配的思路
这题本事hash例题,但考虑到C++字符串的恶意,于是就用了第一次的map输入然后存入map,判断一下就可以了
#include <stdio.h> #include <map> #include <cstring> #include <string> #include <iostream> using namespace std; int main() { char st[300],st1[300],st2[300]; map<string, string> f; while (gets(st)) { if (strlen(st)==0) break; sscanf(st,"%s %s",st1,st2); f[st2]=st1; } string s; string ans; while (cin>>s) { ans=f[s]; if (ans.length()==0) { printf("he\n"); } else printf("%s\n",ans.c_str()); } return 0; }
相关文章推荐
- POJ 2503 Babelfish 字典树经典题 三种方法 (map,排序+二分,字典树)
- POJ_2503_Babelfish_(Trie/map)
- poj 2503 Babelfish (查找 map)
- poj2503——Babelfish(STL,map)
- poj 2503 Babelfish (map)
- poj 2503 Babelfish (map)
- POJ 2503 Babelfish [map & string]
- POJ 2503-Babelfish(STL-map)
- POJ 2503 Babelfish(hash + map)
- Poj 2503 Babelfish(Map操作)
- poj 2503 Babelfish (map,trie 树)
- POJ 2503 Babelfish(人造字典map)
- POJ2503 Babelfish(Map键值对的应用)
- Poj 2503 Babelfish(Map操作)
- POJ 2503-Babelfish(map)
- POJ 2503-Babelfish(map)
- POJ 2503 Babelfish(map,字典树,快排+二分,hash)
- poj_2503_Babelfish(字典树&&map)
- POJ 2503 Babelfish(map,字典树,快排+二分,hash)
- POJ 2503 Babelfish map水过,字典树????