其他分享
首页 > 其他分享> > 遍历map

遍历map

作者:互联网

复习。主要是考场上要用迭代器的时候突然忘了。我是傻逼。放个板子以防以后忘了。

map<int,int>a;
a[3]=3;
a[2]=2;
a[1]=1;
a[100]=1;
map<int,int>::iterator it=a.begin();
while(it!=a.end()){
	if(it->first>100)break;
	printf("%d %d\n",it->first,it->second);
	it++;
}

标签:map,遍历,iterator,printf,100,上要,first
来源: https://www.cnblogs.com/dai-se-can-tian/p/16512042.html