map遍历

//遍历map俩民的元素

#include<map>
#include<string>
#include<iostream>
using namespace std;
int main()
{
    map<string,int>  m;
    m["a"]=1;
    m["b"]=2;
    m["c"]=3;
    map<string,int>::iterator it;
    for(it=m.begin();it!=m.end();++it)
        cout<<"key: "<<it->first <<" value: "<<it->second<<endl;
    return   0;
}

猜你喜欢

转载自blog.csdn.net/whiskey_wei/article/details/80004544