# UVa 10282 ### 題目連結:[UVa10282](http://domen111.github.io/UVa-Easy-Viewer/?10282) ### 題述: 你剛剛搬到另一座城市,那裡的居民說一種外國語言。還好,你有字典可以幫助你翻譯。 --- 輸入首先是字典的內容,最多不會超過100000列。每列包含2個單字(Word,全部小寫且長度不會超過10個字元),第1個是英文,第2個是外國語言。接著有一空白列然後才是需要翻譯的外國語言的單字(每個一列)。在字典中,沒有任一個外國語言單字會出現超過1次。 請參考Sample Input --- 請利用輸入字典資料,將待翻譯的外國語言單字翻成英語。如果在字典中找不到,請輸出"eh" 參考Sample Output ### c++ code: ```cpp= #include<bits/stdc++.h> #include<map> #include<sstream> using namespace std ; int main () { //------------------------------------------------ #ifdef local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif //------------------------------------------------ map<string,string>m ; string a ; string b ; string s ; string tmp ; while( getline( cin , s ) ) { if( s.size() == 0 ) { break; } else { stringstream ss ; ss << s ; ss >> a >> b ; m.insert( pair<string,string>(b,a) ) ; } } while( cin >> s ) { tmp = m[s] ; if ( tmp.size() ) { cout << tmp << endl ; } else { cout <<"eh" << endl ; } } } ``` :::success **``sample input``** dog ogday cat atcay pig igpay froot ootfray loops oopslay atcay ittenkay oopslay ::: :::success **``sample output``** cat eh loops ::: ###### tags: `APCS選修` `C++` `UVa`