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运用实例的更多相关文章

  1. C++ Multimap运用实例—查找元素

    C++ Multimap运用实例—查找元素 #include <map> #include <iostream> #include <algorithm> #inc ...

  2. Vert.x Core 文档手册

    Vert.x Core 文档手册 中英对照表 Client:客户端 Server:服务器 Primitive:基本(描述类型) Writing:编写(有些地方译为开发) Fluent:流式的 Reac ...

  3. Vert.x HTTP 服务器与客户端

    编写HTTP 服务器与客户端 Vert.x让编写非阻塞的HTTP 服务器与客户端变得非常轻松. 创建HTTP 服务器 缺省状况: HttpServer server = vertx.createHtt ...

  4. 最近学习工作流 推荐一个activiti 的教程文档

    全文地址:http://www.mossle.com/docs/activiti/ Activiti 5.15 用户手册 Table of Contents 1. 简介 协议 下载 源码 必要的软件 ...

  5. STL学习系列九:Map和multimap容器

    1.map/multimap的简介 map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. map中key值是唯一的.集合中的元素按一定的顺 ...

  6. STL的基本使用之关联容器:map和multiMap的基本使用

    STL的基本使用之关联容器:map和multiMap的基本使用 简介 map 和 multimap 内部也都是使用红黑树来实现,他们存储的是键值对,并且会自动将元素的key进行排序.两者不同在于map ...

  7. multimap 和 multiset 类型

    map 和 set 容器中,一个键只能对应一个实例.而 multiset 和 multimap 类型则允许一个键对应多个实例.例如,在电话簿中,每个人可能有单独的电话号码列表;在作者的文章集中,每位作 ...

  8. 09--STL关联容器(map/multimap)

    一:map/multimap的简介 map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. map中key值是唯一的.集合中的元素按一定的顺 ...

  9. STL之Map和multimap容器

    1.Map和multimap容器 1)map是标准的关联式容器,一个map是一个键值对序列,即(key,value)对.它提供基于key的快速检索能力. 2)map中key值是唯一的.集合中的元素按一 ...

随机推荐

  1. linux 命令输出保存为文件的三种方式

    一.ls >2.txt        将ls命令直接保存到home文件夹下的2.txt,命令窗口无显示 二.ls | tee 2.txt    也是直接保存在了home文件夹下的2.txt,命令 ...

  2. 性能测试基础---LR运行设置

    ·LR的运行时设置(Runtime settings): ·Run Logic:该选项是用来控制脚本的真正的运行逻辑. ·该选项会把脚本中的函数分别放入三个运行模块中:Init.Run.End ·默认 ...

  3. centos7服务器部署django项目。

    用到的工具,xftp(文件互传),xshell(远程连接) aliyun服务器防火墙开启的端口.80,22(ssh),3306(mysql),8000,9090 部署项目: 1,安装nginx 1&g ...

  4. 四川第十届省赛 A.Angel Beats bitset

    四川第十届省赛 A.Angel Beats bitset 题目链接 题解参考:http://www.cnblogs.com/Aragaki/p/9142250.html 考虑用bitset来维护对于所 ...

  5. springboot ResponseEntity<byte[]> 下载文件 byte 都变成base64

    因为spring boot消息转换器 ,全部将数据转换为json格式,包括文件的byte数据 关于spring boot 的消息转换器见:https://www.jianshu.com/p/ffe56 ...

  6. 15、Python面向对象基础

    和其它编程语言相比,Python 在尽可能不增加新的语法和语义的情况下加入了类机制. Python中的类提供了面向对象编程的所有基本功能:类的继承机制允许多个基类,派生类可以覆盖基类中的任何方法,方法 ...

  7. Codeforces Round #603 (Div. 2) C. Everyone is a Winner! (数学)

    链接: https://codeforces.com/contest/1263/problem/C 题意: On the well-known testing system MathForces, a ...

  8. Mysql命令下导出select查询数据之 select ... into outfile方法

    Mysql日常使用中经常遇到将select查询的数据导出到本地目录的情况,以便数据备份.分析等. 接下来将介绍Mysql终端下使用 select ... into outfile 语句导出数据方法 命 ...

  9. Getting A Mime Type From A File Name In .NET Core

    Getting a mime type based on a file name (Or file extension), is one of those weird things you never ...

  10. vue使用插件的流程

    1.引入vue 2.引入插件 3.通过vue.use()调用 例子:使用router插件 import Vue from "vue"; import VueRouter from ...