abundan @ 2023-10-04 19:40:41
#include <stdio.h>
int main() {
double a[100],b[100],average,x=0,sum=0;
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lf",&a[i]);
sum+=a[i];
}
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i;j++){
if(a[i]>a[i+1]){
double t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
average=(sum-a[0]-a[n-1])/(n-2);
for(int i=0;i<n;i++){
b[i]=a[i]-average;
if(a[i]>average){
b[i]=a[i]-average;
}else{
b[i]=average-a[i];
}
if(b[i]>x){
x=b[i];
}
}
printf("%.2lf %.2lf",average,x);
return 0;
}
by Huangziyu2022 @ 2023-10-15 17:32:14
几分
by XyGetItRightAker @ 2023-12-28 14:16:56
冒泡排序写错了