Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C++

multiset size() trong C++ STL với ví dụ


Trong hướng dẫn này, ta thảo luận về multiset size() trong C++ STL.

Hàm size() trả về số phần tử hiện có trong container.

Ví dụ

#include <bits/stdc++.h> using namespace std; int main(){ multiset<int> s; s.insert(10); s.insert(13); cout << "The size of multiset: " << s.size(); s.insert(13); s.insert(25); cout << "\nThe size of multiset: " << s.size(); s.insert(24); cout << "\nThe size of multiset: " << s.size(); return 0; }

Đầu ra

The size of multiset: 2 The size of multiset: 4 The size of multiset: 5