31:知识点:在multimap中,具有相同关键字的元素会相邻存储
#include<iostream>
#include<string>
#include<fstream>
#include<list>
#include<vector>
#include<map>
#include<set>
#include<cctype>//ctype无法打开,包含tolower()函数和ispunct函数
#include<algorithm>
#include<utility>//保存pair的头文件
using namespace std;
int main(int argc, char**argv)
{
string author = "机械先驱";
multimap<string, string> Library;
Library.insert(make_pair(author,"灭世者的帽子"));
Library.insert(make_pair(author,"法穿杖"));
Library.insert(make_pair(author,"法穿鞋"));
Library.insert(make_pair(author,"冰杖"));
Librar

本文提供了C++Primer第五版第十一章部分习题的答案,聚焦于无序容器如multimap、set的特性和使用。讨论了在multimap中相同关键字的元素存储、set的自动排序、map和set的下标操作以及无序容器的优势。同时,解释了有序与无序容器的区别,包括访问效率和key的排序。
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



