chht_0219 @ 2023-12-19 14:06:27
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,s,minn=100,maxn=0;
cin>>x;
int a[x];
for(int i=1;i<=x;i++){
cin>>a[i];
if(a[i]>maxn){
maxn=a[i];
}
if(a[i]<minn)
minn=a[i];
}
for(int i=1;i<=x;i++){
s=s+a[i];
}
double sum=(s-minn-maxn)/(x-2);
cout<<fixed<<setprecision(2)<<sum;
return 0;
}
by chht_0219 @ 2023-12-19 14:07:19
咋做啊?
by XuYu0317 @ 2023-12-19 14:21:50
你的思路和第二篇题解差不多,可以参考一下第二篇题解的做法。
by chht_0219 @ 2023-12-22 13:14:44
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,minn=100,maxn=0;
double s;
cin>>x;
int a[x];
for(int i=1;i<=x;i++){
cin>>a[i];
if(a[i]>maxn){
maxn=a[i];
}
if(a[i]<minn)
minn=a[i];
s=s+a[i];
}
cout<<fixed<<setprecision(2)<<(s-minn-maxn)/(x-2);
return 0;
}
是这样吗?
by chht_0219 @ 2023-12-22 13:26:55
此帖完
by chht_0219 @ 2023-12-22 13:27:56
互关一下