pppppLF @ 2023-04-19 19:30:40
求指导!
#include <bits/stdc++.h>
using namespace std;
int a[105];
int main(){
int n,max=-1,min=14;
double sum=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+n+1);
for(int i=2;i<=n-1;i++){
sum+=a[i];
}
cout<<fixed<<setprecision(2)<<sum/(n-2);
return 0;
}
by Wildchesse @ 2023-04-19 19:47:30
@pppppLF 数据范围n<=1000,但你a数组就开了105位,数组越界了
by pppppLF @ 2023-04-19 19:51:52
谢谢!