【POJ 2503】Babelfish(水题)stl map存取即可

港控/mmm° 2023-06-01 14:57 93阅读 0赞

题目链接

题目链接 http://poj.org/problem?id=2503

题意

英文A <=> 方言B
输入B,求A

代码如下(G++)

  1. #include <iostream> #include <string.h> #include "map" #include "string" using namespace std; typedef long long ll; double eps = 1e-7; map <string, string> m; int main() { ios::sync_with_stdio(false); string s; do{ getline(cin,s); bool flag = false; for(int i = 0;s[i];++i){ if(s[i] == ' '){ m[s.substr(i+1)] = s.substr(0,i); break; } } }while(s.length()); while(cin >> s){ if(m.find(s) != m.end()){ cout << m[s] << endl; }else{ cout << "eh" << endl; } } return 0; }

转载于:https://www.cnblogs.com/zhangjiuding/p/11476951.html

发表评论

表情:
评论列表 (有 0 条评论,93人围观)

还没有评论,来说两句吧...

相关阅读

    相关 POJ 2503——Babelfish

    这一题也没什么思路很直接,直接用字典树存储信息,在进行查找: 优点:思路直接,速度较快      缺点:占用内存较大,建立的关系是单向的,代码较长 include