zhaoanqiEtayo @ 2023-07-09 16:40:23
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,i,j,a[1000],t;
double aws,sum;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(i=1;i<=n-1;i++)
{
for(j=i+1;j<=n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
sum=0;
for(i=2;i<=n-1;i++)
{
sum=sum+a[i];
}
aws=sum/(n-2);
printf("%.2lf",aws);
return 0;
}
by Terrible @ 2023-07-09 17:08:35
@zhaoanqiEtayo a[1001]
众所周知,a[1000]
的合法下标范围是
by ZachekFalse @ 2023-07-09 17:17:53
@zhaoanqiEtayo 把测评语言改成c++
by ZachekFalse @ 2023-07-09 17:18:38
@zhaoanqiEtayo QWQ
by ZachekFalse @ 2023-07-09 17:59:13
@zhaoanqiEtayo 球关注
by 1000YMH @ 2023-07-26 09:32:35
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,i,s[1001],d=11,f=0;
double g=0;
cin>>a;
for(i=0;i<a;i++){
cin>>s[i];
if(s[i]<d)d=s[i];
if(s[i]>f)f=s[i];
}
for(i=0;i<a;i++)g+=s[i];
g=(g-d-f)/(a-2);
cout<<fixed<<setprecision(2)<<g;
}