map 查找1

#include <stdio.h>
#include
<string.h>
#include
<algorithm>
#include
<map>
#include
<stdlib.h>
#include
<iostream>
#include
<string>

using namespace std;



int main( )
{
map
<string,int>mp;
mp.insert(pair
<string,int>("beijing",50));
mp.insert(pair
<string,int>("shanghai",40));
mp.insert(pair
<string,int>("shenzhen",30));
int a, b;
a
= mp.count("beijing");
b
= mp.count("zhuzhou");
cout
<<a<<" "<<b<<" "<<endl;
// 1 0
// 用count函数判断关键字是否出现
// 找到返回1
return 0;
}

posted on 2011-07-28 21:49  more think, more gains  阅读(183)  评论(0)    收藏  举报

导航