map介绍
2024-12-14 15:41:31
发布于:北京
1,定义
map是存储了键--值--对的容器,键唯一。
2,创建
map<键,值> mp;
map访问类似set,vector.
可自动排序
访问:
map<string,int> ::iterator it;
for(it=mp.begin();it!=mp.end();++it){
cout<<"Key:"<<it->first<<",Value"<<it->second<<endl;
}
简化:
for(auto it:mp){
cout<<"Key:"<<it.first<<",Value:"<<it.second<<endl;
}
这里空空如也
有帮助,赞一个