-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdifference.cpp
45 lines (34 loc) · 1.03 KB
/
difference.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* \file difference.cpp
* \brief
*
* \todo
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
int main ()
{
int first[] = {10, 20, 30, 40, 50, 60, 70};
int second[] = {50, 40, 30, 20, 10};
std::vector<int> v;
std::sort (std::begin(first), std::end(first));
std::sort (std::begin(second), std::end(second));
auto it = std::set_difference(
std::begin(first), std::end(first),
std::begin(second), std::end(second),
std::back_inserter(v));
STD_UNUSED(it);
std::cout << "Difference has " << v.size() << " elements:\n";
for (auto it : v) {
std::cout << ' ' << it;
}
std::cout << '\n';
return 0;
}
//-------------------------------------------------------------------------------------------------
#if 0
5 15 25 100
#endif
//-------------------------------------------------------------------------------------------------