1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <array>
#include <algorithm>
int main() {
std::array<int, 5> numbers = {5, 2, 4, 1, 3};
std::sort(numbers.begin(), numbers.end());
std::cout << "Sorted array: ";
for (int num : numbers) {
std::cout << num << " ";
}
std::cout << std::endl;
auto max_element = std::max_element(numbers.begin(), numbers.end());
std::cout << "Max element: " << *max_element << std::endl;
return 0;
}
Back to array