头文件
#include <set>
代码
#include <set>
#include <iostream>
using namespace std;
int main() {
multiset <int> ms;
ms.insert(1);
ms.insert(5);
ms.insert(5);
ms.insert(5);
ms.insert(2);
ms.insert(1);
for (auto iter = ms.begin(); iter != ms.end(); iter++){
cout << *iter << endl;
}
cout << "end" << endl;
auto iter = ms.find(5);
cout << *iter << endl;
ms.erase(iter);
cout << "end" << endl;
int num = ms.count(5);
cout << "find 5 num is " << num << endl;
cout << "end" << endl;
for (auto iter = ms.begin(); iter != ms.end(); iter++){
cout << *iter << endl;
}
return 0;
};
输出
1
1
2
5
5
5
end
5
end
find 5 num is2
end
1
1
2
5
5
资料:
https://blog.csdn.net/culing2941/article/details/108617870