ytt02_11 @ 2023-03-10 20:39:46
n = int(input())
c = list(map(int, input().split()))
d = float((sum(c)-max(c)-min(c))/3)
print(round(d,2))
by chenzhiyuan0923 @ 2023-03-10 20:47:24
n = int(input())
c = list(map(int, input().split()))
d = float((sum(c)-max(c)-min(c))/(n-2))
print(round(d,2))
by chenzhiyuan0923 @ 2023-03-10 20:47:35
@ytt02_11
by Terrible @ 2023-03-10 20:48:12
@ytt02_11 问题不出在编辑器或解释器上,你再看看题意,除
by ytt02_11 @ 2023-03-10 20:55:30
@chenzhiyuan0923 好的!感谢佬
by ytt02_11 @ 2023-03-10 20:55:48
@Terrible 下次注意!感谢佬!
by fkcufk @ 2023-03-13 19:11:50
C++代码
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
int n;
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i];
sort(a+1,a+n+1);
a[1]=a[n]=0;
int sum=0;
for(int i=1;i<=n;i++) sum+=a[i];
printf("%.2f",1.0*sum/(n-2));
return 0;
}