poj 2503_Babelfish_map lzusa 发布于 2019-04-25 1125 次阅读 题目大意 在一堆字符串中找到匹配的 思路 这题本是hash例题,但考虑到C++字符串的恶意,于是就用了第一次的map 输入然后存入map,判断一下就可以了 #include #include #include #include #include using namespace std; int main() { char st[300],st1[300],st2[300]; map 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; } ]]>
Comments NOTHING