Ответ: #include <iostream>
using namespace std;
int main() {
int n, max, max_index;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (i == 0 || arr[i] > max) {
max = arr[i];
max_index = i;
}
swap(arr[max_index], arr[n-1]);
cout << arr[i] << " ";
cout << endl;
return 0;
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ: #include <iostream>
using namespace std;
int main() {
int n, max, max_index;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (i == 0 || arr[i] > max) {
max = arr[i];
max_index = i;
}
}
swap(arr[max_index], arr[n-1]);
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
return 0;
}
Объяснение: