当前位置:网站首页>STL map属性
STL map属性
2022-07-23 10:37:00 【joker_0030】
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
void MapOther()
{ //定义对象,并赋值。(插入值)
typedef pair<int ,char> in_pair;
map<int,char> db;//<键值,实际值>
db.insert(in_pair(1,'a'));//需要和map的类型一一对应。
db.insert(in_pair(2,'a'));
db.insert(in_pair(3,'a'));
db.insert(in_pair(4,'a'));
db.insert(in_pair(5,'a'));
//map中count判断一个键值是否存在。(得到某一个元素的数量,或者判断一个键值是否存在)。
cout << db.count(1) << endl;
//empty()判断map是否为空。空返回1,反之则0。
cout << db.empty() << endl;
//输出空间大小
cout << db.size()<<endl;
//迭代器输出
map<int, char>::iterator ite = db.begin();
for (ite; ite != db.end();ite++)
{
cout << ite->first << " " << ite->second << endl;
}
}
int main()
{
MapOther();
system("pause");
return 0;
}
边栏推荐
- 什么是Promise?Promise有什么好处
- PostgreSQL has no NVL solution. PostgreSQL queries all tables
- [untitled] test [untitled] test
- VSCode的感叹号+tab的快捷键不能用,以及A-SOUL-live2d插件出问题的解决方法
- 【HiFlow】定期发送腾讯云短信发送群
- The best time to buy and sell stocks
- Common JS modular specification from a code question
- Feignclient utilise un tutoriel détaillé (illustration)
- Force buckle monotone stack
- supervisord安装使用
猜你喜欢

Liunx:浅析vim编辑器基本使用

Linux: analysis of the basic use of vim editor
![[untitled] test [untitled] test](/img/9d/c80dd9a1df2cd6cbbfc597d73a63b2.png)
[untitled] test [untitled] test

基于双目相机拍摄图像的深度信息提取和目标测距matlab仿真

Deep learning single image 3D face reconstruction

安全合理用电 收获清凉一“夏”

Common SQL of Oracle Report

Kettle implémente une connexion de base de données partagée et insère une instance de composant de mise à jour

基于PSO优化的多目标最优值求解matlab仿真

Version correspondence between numpy and pytorch
随机推荐
PostgreSQL has no NVL solution. PostgreSQL queries all tables
Supervisor installation and use
Leetcode-227-basic calculator||
OPNsense – 多功能高可靠易使用的防火墙(二)
修改ssh命令行[[email protected]]#颜色
uniapp实现横向点击滑动菜单
如何实现多个传感器与西门子PLC之间485无线通讯?
7.13WEB安全作业
Redis | 非常重要的中间件
MySQL的大心脏 — 索引
RTA一种广告精准投放的新玩法?
idea一次启动多个项目
pytorch opencv pil图像预处理比较
Is online handling of fund account opening safe? Who can answer it
Chapter 4 use%rest API classes create rest services
Matlab simulation of depth information extraction and target ranging based on binocular camera images
The exclamation point of vscode +tab shortcut key cannot be used, and the solution to the problem of a-soul-live2d plug-in
Blazor快速实现扫雷(MineSweeper)
leetcode-设置交集大小至少为2
动态规划-力扣