Uva 10282 - Babelfish

// https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=0&problem=1223 #include<bits/stdc++.h> using namespace std; int main() { map <string,string>m; int l,i,j,k; while (getline(cin, s) && !s.empty()) { l=s.find(" "); x=""; y=""; for(i=0;i<s.length();i++){ if(i<l) { x+=s[i]; } if(i>l) { y+=s[i]; } } m[y]=x; } while (getline(cin, x) && !x.empty()) { if ( m.find(x) != m.end() ) { cout<<m[x]<<endl; }else{ std::cout << "eh" << std::endl; } } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.