当前位置: 首页 > news >正文

NDK C++ map容器

map容器

// TODO map容器
#include <iostream>
#include <map>using namespace std;int main() {// TODO map<int, string>按key值排序,同一个key不可以重复插入map<int, string> map1;map1.insert(pair<int, string>(1, "111"));map1.insert(pair<int, string>(3, "333"));map1.insert(pair<int, string>(2, "222"));map1.insert(pair<int, string>(2, "2222"));// 修改key对应的 valuemap1[3] = "3333";for (map<int, string>::iterator it = map1.begin(); it != map1.end(); it++) {cout << "key " << it->first << ",value " << it->second << endl;}cout << endl;// TODO multimap<int, string>按key值排序,可以重复插入同的key,使用场景--分组multimap<int, string> multimap1;multimap1.insert(pair<int, string>(1, "111"));multimap1.insert(pair<int, string>(3, "333"));multimap1.insert(pair<int, string>(2, "222"));multimap1.insert(pair<int, string>(2, "2222"));multimap1.insert(pair<int, string>(2, "22"));for (auto it = multimap1.begin(); it != multimap1.end(); it++) {cout << "key " << it->first << ",value " << it->second << endl;}int key;cout << "请输入要查找的key:" << endl;cin >> key;multimap<int, string>::iterator it = multimap1.find(key);for (; it != multimap1.end(); it++) {if (it->first != key) {break;}cout << "key " << it->first << ",value " << it->second << endl;}return 0;
}

http://www.lryc.cn/news/26460.html

相关文章:

  • linux(Centos)安装docker
  • Delphi 中 FireDAC 数据库连接(处理错误)
  • 算法小抄3-理解使用Python容器之列表
  • Vue3中watch的value问题
  • 【线性筛+DP】最大和
  • openpnp - configure - 丢弃(Discard)位置的设置
  • java Object 万字详解 (通俗易懂)
  • Java并发简介(什么是并发)
  • 团队API管理工具-YAPI
  • 学习记录 --- Pytorch优化器
  • Flink State 状态后端分析
  • 和年薪30W的阿里测开工程师聊过后,才知道我的工作就是打杂的...
  • C#开发的OpenRA的界面布局数据加载
  • 并查集结构
  • 全国CSM敏捷教练认证将于2023年3月25-26开班,报名从速!
  • JavaEE进阶第六课:SpringBoot ⽇志⽂件
  • 外置MOS管平均电流型LED降压恒流驱动器
  • python+pytest接口自动化(6)-请求参数格式的确定
  • 开发手册——一、编程规约_3.代码格式
  • 十七、Django-restframework之序列化器(二)
  • python GUI图形化编程-----wxpython
  • 【Python 】yyyy-MM-dd HH:mm:ss 时间格式 时间戳 全面解读超详细
  • 【C++】C++11 异常
  • 关于Thread.start()后的困惑、imap
  • qml学习之qwidget与qml结合使用并调用信号槽交互
  • 【 华为OD机试 2023】 组装新的数组(C++ Java JavaScript Python)
  • 【洛谷 P2089】烤鸡(循环枚举)
  • windows10安装ubantu双系统
  • 【华为OD机试 2023】 人数最多的站点/小火车最多人时所在园区站点(C++ Java JavaScript Python)
  • 2024届暑期实习实录(阿里云大数据研发平台)