Fang_Omega @ 2024-07-17 11:43:28
为什么不对
#include <iostream>
using namespace std;
int lst[1000];
int main()
{
int n, highest = 0, lowest = 10, tmp, highdel = 0, lowdel = 0;
double rslt;
cin >> n;
for (int i; i < n; i++)
{
cin >> tmp;
if (tmp > highest)
{
highest = tmp;
}
if (tmp < lowest)
{
lowest = tmp;
}
lst[i] = tmp;
}
for (int i; i < n; i++)
{
if (lst[i] == highest && highdel == 0)
{
highdel = 1;
continue;
}
if (lst[i] == lowest && lowdel == 0)
{
lowdel = 1;
continue;
}
rslt += lst[i];
}
rslt /= 1.0 * n - 2;
cout << rslt << endl;
return 0;
}
by KY_ABC @ 2024-07-17 12:10:50
#include <iostream>
using namespace std;
int main(){
double a,b,c,d,e;
c = 10000;
d = 0;
cin>>a;
for (int i = 1;i<=a;i++){
cin>>b;
e+=b;
if (b<c){
c = b;
}
if (b>d){
d = b;
}
}
printf("%0.2f",(e-c-d)/(a-2));
return 0;
}
求关
by 自己人 @ 2024-07-21 10:43:13
#include<bits/stdc++.h>
using namespace std;
#define MAXN 11451411
int n,a[100100];
int main(){
int maxn=-MAXN,minn=MAXN,sum=0;
cin>>n;
if(n==2){
cout<<0;
return 0;
}
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
if(a[i]>maxn)maxn=a[i];
if(a[i]<minn)minn=a[i];
}
sum=sum-maxn-minn;
printf("%.2lf",sum*1.0/(n-2));
return 0;
}
by amd47802574 @ 2024-07-26 10:28:43
for里的i初始化呢
by Fang_Omega @ 2024-08-01 22:27:42
谢了