zzxwuhu @ 2024-11-19 18:31:08
#include<stdio.h>
int main(){
int n,i,j,a[10000000],tep;
double x,sum2=0,sum1=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
sum1+=a[i];
}
for(i=1;i<n;i++){
for(j=n-1;j>=i;j--){
if(a[j-i]>a[j]){
tep=a[j];
a[j]=a[j-1];
a[j-1]=tep;
}
}
}
sum2=sum1-a[0]-a[n-1];
x=sum2/(n-2);
printf("%.2lf",x);
}
by Westbrook_ @ 2024-12-08 01:36:09
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+n+1);
double sum=0;
for(int i=2;i<n;i++){
sum+=a[i];
}
printf("%.2lf",sum/(n-2));
}
@zzxwuhu