迭代器遍历 and auto遍历
- 迭代器
map<string,int>::iterator it;
for(it=mp.begin();it!=mp.end();it++)
{
cout<<it->first<< <<it->second<<endl;
} - auto
for(auto l:mp)
{
cout<<l.first<< <<l.second<<endl;
}
map<string,int>::iterator it;
for(it=mp.begin();it!=mp.end();it++)
{
cout<<it->first<< <<it->second<<endl;
}
for(auto l:mp)
{
cout<<l.first<< <<l.second<<endl;
}