1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <set>
#include <array>
#include <iostream>
int main()
{
// a bunch of arrays with a bunch of duplicates
std::array<int, 7> arr1 = { 0, 0, 1, 2, 3, 3, 6 };
std::array<int, 5> arr2 = { -44, -3, -22, -3, -22 };
std::array<int, 4> arr3 = { 1, 6, 6, 6 };
// grab only uniuques out of all 3 arrays
std::set<int> uniques(arr1.begin(), arr1.end());
uniques.insert(arr2.begin(), arr2.end());
uniques.insert(arr3.begin(), arr3.end());
// show result
for (const auto& ref : uniques)
std::cout << ref << std::endl;
std::cin.get();
}
|