借助示例理解 C++ STL 中的 multiset max_size()
在本文中,我们将讨论一个程序,它帮助理解 C++ STL 中的 multiset max_size()。
函数 max_size() 返回一个给定容器可以容纳的最大元素数。
示例
#include <bits/stdc++.h>
using namespace std;
int main(){
multiset<int> s;
s.insert(10);
s.insert(13);
s.insert(13);
s.insert(25);
s.insert(24);
cout << "The multiset elements are: ";
for (auto it = s.begin(); it != s.end(); it++)
cout << *it << " ";
cout << "\nThe max size of multiset: " << s.max_size();
return 0;
}输出
The multiset elements are: 10 13 13 24 25 The max size of multiset: 461168601842738790
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP