#include<map>
#include<iostream>
using namespace std;
int main()
{
map<int,int>m;
int i;
for(i=0;i<10;i++)
m[i]=2-i;
map<int,int>::iterator it;
for(it=m.begin();it!=m.end();it++)
cout<<it->first<<" "<<it->second<<endl;
//system("pause");
return 0;
}
输出:
![](https://i-blog.csdnimg.cn/blog_migrate/e0c3dab2550c3b07bdadc3d7c62a2f23.png)