map的 简单用法

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

       map<string,int> mapStudent;
       mapStudent["student_one\0"]=1;
       mapStudent["student_two\0"]=2;
       mapStudent["student_three\0"]=3;
       if(mapStudent.find("student_four\0")==mapStudent.end())
        mapStudent["student_four\0"]=4;
       if(mapStudent.find("student_four\0")!=mapStudent.end())
        printf("%d\n",mapStudent["student_four\0"]);
       return 0;
}

 

posted @ 2013-09-27 11:03  galaxy77  阅读(159)  评论(0编辑  收藏  举报