map的 简单用法

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

       map<string,int> mapStudent;
       mapStudent["student_one"]=1;
       mapStudent["student_two"]=2;
       mapStudent["student_three"]=3;
       if(mapStudent.find("student_four")==mapStudent.end())
        mapStudent["student_four"]=4;
       if(mapStudent.find("student_four")!=mapStudent.end())
        printf("%d
",mapStudent["student_four"]);
       return 0;
}
原文地址:https://www.cnblogs.com/assult/p/3342367.html