#include <iostream>
#include <set>
#include <vector>
using namespace std;
template <class T>
void print(T& c){
for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
std::cout << *i << endl;
}
}
int main(){
const int num_grades = 11;
const int grade[num_grades] = { 2, 5, 3, 8, 9, 9, 6, 3, 5, 9, 10 };
set<int> unique( grade, grade+num_grades );
multiset<int> all( grade, grade+num_grades );
print( unique );
print( all );
const int drop_grade = 5;
multiset<int>::iterator spot = all.find( drop_grade );
if( spot != all.end() ) {
all.erase( spot );
if( all.count( drop_grade ) == 0 )
unique.erase( drop_grade );
}
else
cout << "Couldn't find a grade of " << drop_grade << endl;
print( unique);
print( all);
}
|