#include
#include
#include
#include
#include
using namespace std;
template
void print(T& c){
for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
std::cout << *i << endl;
}
}
int main( )
{
const int num_years = 5;
const char* d[num_years] = { "A", "B","C", "D", "E" };
const char* d2[num_years] = { "a", "b","c", "d", "e" };
const char* d3[num_years] = { "1","2", "3", "4", "5" };
multiset s1( d,d+num_years );
multiset s2( d2,d2+num_years );
multiset s3( d3,d3+num_years );
print( s1 );
print( s2 );
print( s3 );
vector winner;
merge( s1.begin(), s1.end(),s2.begin(), s2.end(), back_inserter( winner ) );
vector all_winner;
merge( winner.begin(), winner.end(),s3.begin(), s3.end(), back_inserter( all_winner ) );
all_winner.erase( unique( all_winner.begin(), all_winner.end() ),all_winner.end() );
cout << endl << all_winner.size() << " UNIQUE WINNERS\n";
for( vector::size_type i = 0; i < all_winner.size(); ++i )
{
cout << all_winner[i] << " ";
if( (i+1) % 5 == 0 )
cout << endl;
}
}