迭代器遍历 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;
    }

posted @ 2022-04-19 20:54  xxj112  阅读(88)  评论(0)    收藏  举报