zhangjialing1234 @ 2025-01-10 16:58:09
#include <iostream>
using namespace std;
double a[305];
int main(){
int n;
double max1 = 0, min1 = 99999999, sum = 0;
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] > max1){
max1 = a[i];
}
if(a[i] < min1){
min1 = a[i];
}
sum = sum + a[i];
}
sum = sum - min1 - max1;
double max2 = 0, min2 = 9999999, ans;
for(int i = 0; i < n; i++){
if(a[i] != max1 && a[i] > max2){
max2 = a[i];
}
if(a[i] != min1 && a[i] < min2){
min2 = a[i];
}
}
if(sum / (n - 2) - min2 >= max2 - sum / (n - 2)){
ans = sum / (n - 2) - min2;
}else{
ans = max2 - sum / (n - 2);
}
printf("%.2lf %.2lf", sum / (n - 2), ans);
return 0;
}