藉助示例理解 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