#include<iostream>
#include<set>
using namespace std;
int main ( )
{
// Declaration
multiset<double>
S1;
// Assignment
S1.insert
(5.0);
S1.insert (3.2);
S1.insert (3.2);
S1.insert (4.6);
S1.insert (5.0);
S1.insert (6.0);
S1.insert
(3.2);
S1.insert (7.0);
S1.insert
(7.0);
S1.insert (2.9);
S1.insert (1.1);
S1.insert (6.5);
// Declaration of the iterator pos
multiset<double>
:: iterator pos;
// Print S1
for
(pos=S1.begin( );pos!=S1.end( );++pos) {
cout << *pos << " ";
}
cout <<
endl;
// Remove the first element having for value 3.2
pos=S1.find(3.2);
if
(pos!=S1.end( )) S1.erase(pos);
// Print S1
for
(pos=S1.begin( );pos!=S1.end( );++pos) {
cout << *pos << " ";
}
cout << endl;
// Dynamic declaration of S2 is allowed
multiset
<double,greater<double> > S2;
// Assinement of S2 with the same values than S1
for (pos=S1.begin( );pos!=S1.end(
);++pos) {
S2.insert(*pos);
}
// Remove all the 7.0 from V2
S2.erase(7.0);
// Print all the elements of V2 greater than
5.0
for
(pos=S2.begin ( );pos!=S2.find(5.0);++pos) {
cout << *pos << " ";
}
cout << endl;
}