Do_www @ 2022-11-27 13:09:52
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int a[500];
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
double min = 100;
double max = -1;
double sum = 0;
for (int i = 1; i <= n; i++)
{
if (a[i]< min)
{
min = a[i];
}
if (a[i] > max)
{
max = a[i];
}
sum += a[i];
}
cout << fixed << setprecision(2) << (sum - max - min) / (n - 2) << endl;
return 0;
}```
by WA_sir @ 2022-11-27 13:18:49
@wry_123 数组开小了,应该开到
by rainbow_automaton @ 2022-11-27 13:19:06
a数组开小了吧,题中给的
by Do_www @ 2022-11-27 13:26:24
@WA_sir 感谢,已关
by Alone_Moonking @ 2022-11-27 13:51:53
#include<bits/stdc++.h>
using namespace std;
float n,a[1020];
int maxn=-1,minn=11;
int main()
{
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
ans+=a[i];
if(a[i]>maxn)
{
maxn=a[i];
}
if(a[i]<minn)
{
minn=a[i];
}
}
cout<<fixed<<setprecision(2)<<(ans-maxn-minn)/(n-2);
}
by Alone_Moonking @ 2022-11-27 13:52:07
@wry_123
by lianchanghua @ 2022-12-31 15:55:34
@wry_123 ) n(n≤1000)