an_xi @ 2021-11-24 16:54:04
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
int n,i,max=0,min=10,a;
float ed;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&a);
if(a>max) max=a;
if(a<min) min=a;
ed+=1.0*a;
}
ed=ed-max-min;
ed=ed/(n-2);
printf("%.2f\n",ed);
return 0;
}
by Buried_Dream @ 2021-11-24 16:55:54
这边建议您用 double
, float
基本用不上
by an_xi @ 2021-11-24 16:59:29
@TLE_Automation 确实是这个问题,谢谢dalao(所以为什么float不行)
by Mei_Misaki @ 2021-11-24 17:02:57
@an_xi 精度低
by Buried_Dream @ 2021-11-24 17:03:38
@an_xi
据我所知 float
是单精度, double
是双精度,可能是 float
被卡精度了(我不也是很清楚,不过关于小数我一般只用double
.
by Buried_Dream @ 2021-11-24 17:04:54
精度更高的推荐用 long double
.
by an_xi @ 2021-11-24 17:05:21
悟了,以后把float扣掉