开挂的map

来源:互联网 发布:cnas 软件测试实验室 编辑:程序博客网 时间:2024/05/21 22:31

转自: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;}
0 0
原创粉丝点击