#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
map<int,int> m;
m[54]=96;
m[6]=84;
map<int,int>::iterator it;
for(it=m.begin();it!=m.end();it++){
cout << it->first << " " << it->second << endl;
}
}
输出为:
6 84
54 96
可见,map输出时会按键自动排序而非vector中的输出