开挂的map

转自:http://blog.csdn.net/sunshinewave/article/details/8067862

#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    map<int,string>mapstudent;

    mapstudent.insert(pair<int,string>(1,"student_one"));
    mapstudent.insert(pair<int,string>(2,"student_two"));
    mapstudent.insert(pair<int,string>(3,"student_three"));
    map<int,string>::iterator iter;
    for(iter=mapstudent.begin();iter!=mapstudent.end();iter++)
    {
        cout<<iter->first<<" "<<iter->second<<endl;
    }
    cout<<endl;
    mapstudent[1]="student_one";
    mapstudent[2]="student_two";
    mapstudent[3]="student_three";
    for(iter=mapstudent.begin();iter!=mapstudent.end();iter++)
    {
        cout<<iter->first<<" "<<iter->second<<endl;
    }
    int map_size=mapstudent.size();
    cout<<map_size<<endl;
    mapstudent.clear();
    if(mapstudent.empty())
    cout<<"lalalala"<<endl;
}
posted @ 2016-05-15 19:19  see_you_later  阅读(104)  评论(0编辑  收藏  举报