BLX32M_10 @ 2022-02-17 11:35:27
#include <cstdio>
#include <algorithm>
long double a[1005], ans;
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%lf", &a[i]);
std::stable_sort(a, a + n);
for (int i = 1; i < n - 1; i++)
ans += a[i];
printf("%.2lf", ans / n);
return 0;
}
by 02Ljh @ 2022-02-17 11:38:24
兄弟,你
ans
没给初始值0
by zcxxxxx @ 2022-02-17 11:38:33
ans / (n - 2),别用long double
by zcxxxxx @ 2022-02-17 11:40:16
@02Ljh ans 在那个地方定义初始值就是 0
by 02Ljh @ 2022-02-17 11:42:30
@zcxxxxx 主要是我不常用全局变量 谢谢 :)
by zcxxxxx @ 2022-02-17 11:43:39
long double 不是那样输出
by RockyYue @ 2022-02-17 11:46:40
long double应该是"%.2Lf",L大写