map
来源:互联网 发布:网络系统工程师考试 编辑:程序博客网 时间:2024/05/16 14:30
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;
void main()
{
//定义map 对象
map<string,int> word;
//定义指针
map<string,int>::iterator it;
//向word 插入元素 ("a",9)
word.insert (map<string,int>::value_type("a",9));
//查找 键是"a"的元素,返回指向元素的指针。
it=word.find ("a");
//如果元素不存在,指针指向word.end().
if(it!=word.end ())
cout<<it->second<<endl; //输出元素的值
//查找 键是"a"的元素,
int result=word.count ("a");
//如果键存在返回1,否则返回0
if(result)
cout<<word["a"]<<endl; //输出元素的值
cout<<endl;
}
0 0
- map
- MAP
- map
- MAP
- map
- map
- map
- Map
- Map
- Map
- map
- map
- Map
- .map
- map
- MAP
- map
- Map
- VS2008反汇编小解(转)
- Android之drawable state各个属性详解
- USACO 1.3 Calf Flac (calfflac)
- 判断一个单链表是否有环及环的链接点(转)
- c#中属性和字段的区别?
- map
- VS :对象被多次指定;已忽略多余的指定
- java加密算法
- 用来新建用户根目录的脚本
- C#学习笔记——摄像头
- checkForm 表单验证
- USACO 1.3 Prime Cryptarithm (crypt1)
- 三大框架的工作原理(Strut1,Strut2,Hibernate,Spring)
- 如何禁用一个easyui组件