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

题目链接

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

题意

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

Code(G++)

#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;
}

猜你喜欢

转载自blog.csdn.net/zhangjiuding/article/details/100583443