迭代器遍历 and auto遍历

  1. 迭代器

    map<string,int>::iterator it;
    for(it=mp.begin();it!=mp.end();it++)
    {
    cout<<it->first<< <<it->second<<endl;
    }

  2. auto

    for(auto l:mp)
    {
    cout<<l.first<< <<l.second<<endl;
    }