xiaosujiayou @ 2024-03-19 11:20:38
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int a[500],b[500],maxn=-1,minn=1e9,sum1=0,sum2=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
maxn=max(maxn,a[i]);
minn=min(minn,a[i]);}
for(int i=1;i<=n;i++){
if(a[i]!=maxn&&a[i]!=minn)
sum1+=a[i];}
cout<<fixed<<setprecision(2)<<sum1/(n-2)<<" ";
for(int i=1;i<=n;i++){
if(a[i]!=maxn&&a[i]!=minn)
b[i]=fabs(a[i]-1.0*sum1/(n-2));
sum2+=b[i];}
cout<<fixed<<setprecision(2)<<sum2;
return 0;
}
by sll00 @ 2024-03-19 12:37:39
@xiaosujiayou 数据类型最好写成double, 然后题目求的是误差最大值不是总误差,你样例都跑出来是错的(11.00 2.00)