#include <iostream>
#include <ctime>
#include <algorithm>
signed main() {
setlocale(LC_ALL, "Rus");
srand(time(NULL));
int n;
std::cout << "Размер массива: ";
std::cin >> n;
int* arr = new int[n];
std::cout << "Исходный массив: ";
for (int i = 0; i < n; i++) {
arr[i] = rand() % 10;
std::cout << arr[i] << " ";
}
for (int j = 0; j < n-1; j++) {
if (arr[j] > arr[j + 1])
std::swap(arr[j], arr[j + 1]);
std::cout << std::endl << arr[n - 1] + arr[n - 2];
return 0;
#include <iostream>
#include <ctime>
#include <algorithm>
signed main() {
setlocale(LC_ALL, "Rus");
srand(time(NULL));
int n;
std::cout << "Размер массива: ";
std::cin >> n;
int* arr = new int[n];
std::cout << "Исходный массив: ";
for (int i = 0; i < n; i++) {
arr[i] = rand() % 10;
std::cout << arr[i] << " ";
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n-1; j++) {
if (arr[j] > arr[j + 1])
std::swap(arr[j], arr[j + 1]);
}
}
std::cout << std::endl << arr[n - 1] + arr[n - 2];
return 0;
}