liujunyu66666666666 @ 2023-12-06 16:29:20
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
doublea[n],sum=0,u=0,l=1000000,e,q;;
double ou;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
if(a[i]>=u)
{
u=a[i];
}
if(a[i]<=l)
{
l=a[i];
}
}
sum=sum-u-l;
sum=sum/(n-2);
printf("%.2lf",sum);
cout<<" ";
e=sum-l;
q=u-sum;
if(e>q)
printf("%.2lf",e-1);
else
printf("%.2lf",q-1);
return 0;
}
//只通5个
by 12345limengqi @ 2023-12-13 18:17:46
@liujunyu66666666666
by liujunyu66666666666 @ 2023-12-14 12:28:40
?
by liujunyu66666666666 @ 2023-12-14 12:29:26
@12345limengqi 不是很懂 啥是最后if的地方“不一定是差1”?
by 12345limengqi @ 2023-12-14 12:50:19
if(e>q)
printf("%.2lf",e-1);//这不一定差1
else
printf("%.2lf",q-1);
return 0;
}
by 12345limengqi @ 2023-12-14 15:05:21
if(e>q)
printf("%.2lf",e-1);//不一定是差1
//应该是次小值和次大值减去平均然后比较
else
printf("%.2lf",q-1);
return 0;
}
by liujunyu66666666666 @ 2023-12-19 12:30:21
@12345limengqi 感谢