1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <set>
#include <algorithm>
#include <iterator>
int main()
{
std::multiset<int> first { 1, 2, 2, 3, 3, 3, 4, 5, 5, 6, 7, 7, 7, 7, 8 } ;
std::multiset<int> second { 1, 2, 2, 3, 4, 5, 6, 7, 8 } ; // mising two 3s, one 5 and three 7s
std::cout << "numbers that are missing in the second set are: " ;
std::set_difference( first.begin(), first.end(), second.begin(), second.end(),
std::ostream_iterator<int>( std::cout, " " ) ) ; // 3 3 5 7 7 7
std::cout << '\n' ;
}
|