kjhChina6 @ 2024-11-30 21:19:24
#include<bits/stdc++.h>
using namespace std;
double a[350],jun=0,cha=0;
int main(){
int n;
cin>>n;
double maxx=-1000,minn=9999999999;
for(int i=1;i<=n;i++){
scanf("%lf",&a[i]);
if(maxx<a[i]){
maxx=a[i];
}
if(minn>a[i]){
minn=a[i];
}
jun+=a[i];
}
jun=jun-maxx-minn;
jun=jun/(n-2);
maxx=0;
for(int i=1;i<=n;i++){
if(a[i]>jun){
cha=a[i]-jun;
}
if(a[i]<jun){
cha=jun-a[i];
}
if(maxx<cha){
maxx=cha;
}
}
printf("%.2lf",jun);
cout<<' ';
printf("%.2lf",cha);
return 0;
}
为啥错,大神教一下