C++ Multimap运用实例
C++ Multimap运用实例
#include <map>
#include <string>
#include <iostream>
#include <iomanip> using namespace std; int main()
{
multimap<string, string> dict1;
dict1.insert({ { "day","Tag" }, { "strange","fremd" }, { "car","Auto" },
{ "smart","elegant" }, { "trait","Merkmal" }, {"strange","seltsam"},
{ "smart","raffiniert" }, { "smart","klug" }, {"clever","raffiniert"} }); //print all element
cout.setf(ios::left,ios::adjustfield);
cout << "" << setw() << "english german " << endl;
cout << setfill('-') << setw() << " " << setfill(' ') << endl; for (const auto& elem1:dict1)
{
cout << " " << setw() << " " << elem1.first << " " << elem1.second << endl;
}
cout << endl; string word1("smart");
cout << "word1:" << word1 << endl;
for (auto pos1 = dict1.lower_bound(word1);pos1 != dict1.upper_bound(word1);++pos1)
{
cout << "" << pos1->first << " " << pos1->second << endl;
}
cout << endl; string word2("raffiniert");
cout << "word2:" << word2 << endl;
for (const auto& elem1:dict1)
{
if (elem1.second == word2)
{
cout << elem1.first << " " << elem1.second << endl;
}
} system("pause");
return ;
}
english german
------------------
car Auto
clever raffiniert
day Tag
smart elegant
smart raffiniert
smart klug
strange fremd
strange seltsam
trait Merkmal
word1:smart
smart elegant
smart raffiniert
smart klug
word2:raffiniert
clever raffiniert
smart raffiniert
请按任意键继续. . .
代码参考:C++标准库(第2版)
C++ Multimap运用实例的更多相关文章
- C++ Multimap运用实例—查找元素
C++ Multimap运用实例—查找元素 #include <map> #include <iostream> #include <algorithm> #inc ...
- Vert.x Core 文档手册
Vert.x Core 文档手册 中英对照表 Client:客户端 Server:服务器 Primitive:基本(描述类型) Writing:编写(有些地方译为开发) Fluent:流式的 Reac ...
- Vert.x HTTP 服务器与客户端
编写HTTP 服务器与客户端 Vert.x让编写非阻塞的HTTP 服务器与客户端变得非常轻松. 创建HTTP 服务器 缺省状况: HttpServer server = vertx.createHtt ...
- 最近学习工作流 推荐一个activiti 的教程文档
全文地址:http://www.mossle.com/docs/activiti/ Activiti 5.15 用户手册 Table of Contents 1. 简介 协议 下载 源码 必要的软件 ...
- STL学习系列九:Map和multimap容器
1.map/multimap的简介 map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. map中key值是唯一的.集合中的元素按一定的顺 ...
- STL的基本使用之关联容器:map和multiMap的基本使用
STL的基本使用之关联容器:map和multiMap的基本使用 简介 map 和 multimap 内部也都是使用红黑树来实现,他们存储的是键值对,并且会自动将元素的key进行排序.两者不同在于map ...
- multimap 和 multiset 类型
map 和 set 容器中,一个键只能对应一个实例.而 multiset 和 multimap 类型则允许一个键对应多个实例.例如,在电话簿中,每个人可能有单独的电话号码列表;在作者的文章集中,每位作 ...
- 09--STL关联容器(map/multimap)
一:map/multimap的简介 map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. map中key值是唯一的.集合中的元素按一定的顺 ...
- STL之Map和multimap容器
1.Map和multimap容器 1)map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. 2)map中key值是唯一的.集合中的元素按一 ...
随机推荐
- Odoo graph视图
转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826175.html 一:图形视图 图形视图用来表示对模型的概述和分析,根元素是<graph> ...
- 《linux就该这么学》课堂笔记11 LVM、防火墙初识
1.常用的LVM部署命令 功能/命令 物理卷管理 卷组管理 逻辑卷管理 扫描 pvscan vgscan lvscan 建立 pvcreate vgcreate lvcreate 显示 pvdispl ...
- httprunner学习22-正则表达式提取(extract)与校验(validate)
前言 有些接口返回的并不是json格式的内容,返回的是html或者xml格式的内容,这种就不能用前面的 content.的方法去提取了. httprunner 支持正则表达式提取(extract)参数 ...
- python中的特殊注释#todo与#type
0904自我总结 python中的特殊注释 一.#TODO 这个注释用来快熟找到内容 #todo这里的todo不用区分大小写 写法标记的位置,#todo 备注内容 二.#type a = 1 #typ ...
- 一些坑 Java 执行命令行命令 Spring Boot 打包为jar ResourceUtils.getFile 等出现的问题
Java 执行命令行命令 这个没技术含量的东西耗费了我半个多小时 String command = ....; Process process = Runtime.getRuntime().exec( ...
- jmeter,badboy,jar包文件 常数吞吐量计时器?
badboy录制脚本 1.按f2 红色开始录制 URL输入:https://www.so.com/ 2.搜索框输入zxw 回车键搜索 3.选中关键字(刮例如zxw软件——>tools——> ...
- C++后端工程师需要看的书籍
C++基础书籍<C++ primer><深度探索C++对象模型><Effective C++><more effective C++><STL源码 ...
- C++ Boost
Boost库是一个可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一. Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容.在C+ ...
- 2019-09-16 16:42:03.621946: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA Traceback (most recent cal
-- ::] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA ...
- ubuntu笔记1-vim安装报错
ubuntu安装vim的时候,报错提示:vim : 依赖: vim-common (= 2:7.3.429-2ubuntu2) 但是 2:7.3.429-2ubuntu2.1 正要被安装 说明既存的v ...