This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

33
TangDou/LianXiTi50/35.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int INF = 0x3f3f3f3f;
int a[N];
/**
用例: 23 54 34 12 76
结果: 76 54 34 23 12
*/
int main() {
int n = 5;
int Max = -INF, Min = INF;
int Max_pos, Min_pos;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] > Max) {
Max = a[i];
Max_pos = i;
}
if (a[i] < Min) {
Min = a[i];
Min_pos = i;
}
}
swap(a[1], a[Max_pos]);
swap(a[n], a[Min_pos]);
for (int i = 1; i <= n; i++) cout << a[i] << " ";
return 0;
}