A宋锦瑞A @ 2021-06-25 10:41:26
输出怎么换成2位小数,样例一直是7.66667?
by A宋锦瑞A @ 2021-06-25 10:42:37
代码:
#include<bits/stdc++.h>
using namespace std;
int n;
float a[1010],num=0.00,Min,Max;
int main()
{
cin>>n;
for(int i=0;i<=n-1;i++)
{
cin>>a[i];
if(i==0)
{
Min=a[i];
Max=a[i];
}
else
{
if(Min>a[i])
{
Min=a[i];
}
if(Max<a[i])
{
Max=a[i];
}
}
num+=a[i];
}
num-=Max+Min;
num/=n-2;
cout<<num;
return 0;
}
by Ninelife_Cat @ 2021-06-25 10:54:33
@A宋锦瑞A cout<<fixed<<setprecision(2)<<num;
by A宋锦瑞A @ 2021-06-25 10:56:02
感谢,已AC?
by _l_l_l_l_l_ @ 2021-06-25 11:04:21
@A宋锦瑞A printf("%.2lf",num);