STL库里面的容器还是很好用的
比如说
priority_queue
vector
今天学一个map
定义:
map<数据类型,数据类型>容器名;
怎么记呢?背单词呗~英语书欢迎你
map型按first升序排序
加东西用(map<x,y>z)
z[add]=context;就行了
map的枚举:
map<x,y>::iterator I;
可以用I枚举了(欲写代码,先背单词)
放道题
#include<iostream.h>
#include<map>
using namespace std;
#define in Read()
#define re register
map<string,string>word;
char ch[50],a[50],b[50];
string st;
int main(){
while(gets(ch)&&ch[0]!='\0'){
sscanf(ch,"%s %s",a,b);
word[b]=a;
}
while(cin>>st){
if(word.find(st)!=word.end()){
cout<<word[st]<<endl;
}
else cout<<"eh"<<endl;
}
return 0;
}