#include#include #include int main() { std::array arr{5, 4, 3, 2, 1}; std::sort(arr.begin(), arr.end()); for (auto i : arr) { std::cout << i << " "; } return 0; }
#includeIn this example, we create an array of integers of size 5, where each element is initialized to zero. We then use a for-loop to iterate through the array and set each element equal to its corresponding index. Finally, we iterate through the array and output each element.#include int main() { std::array arr{} for (int i = 0; i < arr.size(); ++i) { arr[i] = i; } for (auto i : arr) { std::cout << i << " "; } return 0; }