KXY_Moon @ 2024-09-14 14:07:25
#include <bits/stdc++.h>
using namespace std;
int n,s[1005],sum[1005],a[1005];
int main()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>s[i];
sort(s+1,s+n+1);
for(int i=1,j=2;j<=n-1;j++,i++) a[i]=s[j];
for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
double ans=sum[n]/(n-2);
cout<<fixed<<setprecision(2)<<ans;
return 0;
}
by JimmyQ @ 2024-09-14 14:15:46
#include <bits/stdc++.h>
using namespace std;
int n,s[1005];
double sum[1005],a[1005];
int main()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>s[i];
sort(s+1,s+n+1);
for(int i=1,j=2;j<=n-1;j++,i++) a[i]=s[j];
for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
double ans=sum[n-2]/(n-2);
cout<<fixed<<setprecision(2)<<ans;
return 0;
}
by JimmyQ @ 2024-09-14 14:16:24
@KXY_Moon
by JimmyQ @ 2024-09-15 12:13:01
@KXY_Moon 求关