2.答案
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int arr[10],n;
int maxi = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d",& arr[i]);
}
int max = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] > max)
{
max = arr[i];
maxi = i;
}
}
int temp;
temp = arr[0];
arr[0] = arr[maxi];
arr[maxi] = temp;
int min = arr[0];
int mini = 0;
for (int i = 0; i < n; i++)
{
if (arr[i] < min)
{
min = arr[i];
mini = i;
}
}
int str;
str = arr[n - 1];
arr[n - 1] = arr[mini];
arr[mini] = str;
for (int i = 0; i < n; i++)
{
printf("%d ", arr[i]);
}
return 0;
}