求助

P5726 【深基4.习9】打分

xhy_0130 @ 2024-07-12 13:09:55

#include<bits/stdc++.h>
using namespace std;
double n,m,sum,maxn=0,minn=9999999;
int main()
{
  cin>>n;
  for(int i=1;i<=n;++i)
  {
    cin>>m;
    maxn=max(maxn,m);
    minn=min(minn,m);
    sum+=m;
  }
  sum-=maxn;
  sum-=minn;
  sum=sum/(n-2);
  cout<<sum;
  return 0;
} 

by xhy_0130 @ 2024-07-12 13:18:57

范例数据输出7.66667不知道为啥QAQ


by NullPointerExpection @ 2024-07-12 13:27:16

@xhy_0130 保留2位小数


by xhy_0130 @ 2024-07-12 13:31:18

@NullPointerExpection 咋保我是蒟蒻不会


by NullPointerExpection @ 2024-07-12 13:35:26

@xhy_0130

cout << fixed << setprecision(2) << sum;

by meifan666 @ 2024-07-12 13:37:01

@xhy_0130

这个简单

printf("%.2lf,sum);

|