Do you mean something like:
Code:#include <iostream> #include <algorithm> constexpr size_t ELEMENTS { 8 }; constexpr size_t SLOTS { 32 }; void show(const int(&arr)[ELEMENTS]) { for (const auto& c : arr) std::cout << c; std::cout << '\n'; } void bool_element_option_03(const int(&arr_value)[ELEMENTS], int(&arr_copy_value)[ELEMENTS], int(&arr_elements)[ELEMENTS][SLOTS]) { std::copy(std::begin(arr_value), std::end(arr_value), std::begin(arr_copy_value)); std::sort(std::rbegin(arr_copy_value), std::rend(arr_copy_value)); for (const auto& e : arr_elements) for (const auto& v : e) std::cout << v << ' '; std::cout << '\n'; std::cout << "\nReverse sorted:\n"; show(arr_copy_value); } int main() { const int arr_value[ELEMENTS] { 1, 2, 9, 4, 5, 6, 7, 8 }; int arr_copy_value[ELEMENTS] {}; int arr_elements[ELEMENTS][SLOTS] {}; std::cout << "\nOriginal order:\n"; show(arr_value); bool_element_option_03(arr_value, arr_copy_value, arr_elements); }




Reply With Quote
