代码实现
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n;
int a[100001];
int mx,mm,mn; // 最大值、中位数、最小值
double mm2;
int main()
{
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
mx = max(a[0],a[n-1]);
mn = min(a[0],a[n-1]);
cout<<mx<<" ";
if(n%2) // 奇数个
{
mm = a[(n-1)/2];
cout<<mm;
}
else {// 偶数个
if((a[n/2]+a[n/2-1])%2){
mm2 = 0.5*(a[n/2]+a[n/2-1]);
printf("%.1f",mm2);
}
else{
mm = (a[n/2]+a[n/2-1])/2;
cout<<mm;
}
}
cout<<" "<<mn<<endl;
return 0;
}