#include <iostream>
#include <set>
using namespace std;
typedef multiset<int> MSETINT; // MSETINT是别名,
int main()
{
MSETINT a;
a.insert(67);
a.insert(7);
a.insert(-2);
a.insert(20);
a.insert(50);
MSETINT::const_iterator i;
cout << "multiset里有" << a.size() << "个数据。" << endl;
cout << "每个数据是:" << endl;
for (i = a.begin(); i != a.end(); ++i)
{
cout << *i << endl;
}
int nNumberToErase = 0;
cin >> nNumberToErase;
a.erase(nNumberToErase);
cout << "删除后:" << endl;
cout << "multiset里有" << a.size() << "个数据。" << endl;
cout << "每个数据是:" << endl;
for (i = a.begin(); i != a.end(); ++i)
{
cout << *i << endl;
}
return 0;
}
set集的删除
最新推荐文章于 2023-07-06 10:10:16 发布