ZOJ1109 使用了C++中的map容器这时问题就会变得很简单,不过我想下次不用模板做下
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<map> 6 7 using namespace std; 8 9 map<string,string>entry; 10 map<string,string>::iterator location,pos; 11 int main() 12 { 13 14 char line[30]; 15 char english[11],mouse[11]; 16 string value,key; 17 18 while(gets(line)) 19 { 20 if(strlen(line)==0) break; 21 sscanf(line,"%s%s",english,mouse); 22 key = mouse; 23 value = english; 24 entry[key] = value; 25 } 26 while(cin>>line) 27 { 28 location = entry.find(line); 29 if(location != entry.end()) 30 cout<<entry[line]<<endl; 31 else cout<<"eh"<<endl; 32 } 33 return 0; 34 }