#include #include #include #include #include #include struct IsEven { bool operator()(const int& value) { return value % 2 == 0; } }; int main() { /* initialize values and fill it with shuffled values 1..100 */ std::vector values(100); std::iota(values.begin(), values.end(), 1); std::shuffle(values.begin(), values.end(), std::mt19937(2)); /* select all even values out of it */ std::vector selected_values; std::copy_if(values.begin(), values.end(), std::back_inserter(selected_values), IsEven()); /* print selected values */ int count = 0; for (auto value: selected_values) { std::cout << std::setw(4) << value; if (++count % 10 == 0) std::cout << std::endl; } }