ZOJ1109 使用了C++中的map容器这时问题就会变得很简单,不过我想下次不用模板做下

View Code
 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 }

 

posted @ 2012-04-26 15:23  zhongya  阅读(196)  评论(0编辑  收藏  举报