全部wa,求改!!!

P5726 【深基4.习9】打分

liuzicheng100 @ 2024-10-22 17:38:19

这是源代码 :

#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
    int n,ma=0,mi=2000000000,c=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]>ma)ma=a[i];
        if(a[i]<mi)mi=a[i];
    }
    for(int i=1;i<=n;i++){
        if(ma==a[i])c+=0;
        else if(mi==a[i])c+=0;
        else c+=a[i];
    }
    cout<<c;
}

by SunXiaolang @ 2024-10-22 17:43:25

@liuzicheng100 精准到两位数


by SunXiaolang @ 2024-10-22 17:55:05

@liuzicheng100 再说你这个不用特意加0,只需要把其中的一个最大的和最小的给设为0就好了。


by SunXiaolang @ 2024-10-22 17:55:52

#include<bits/stdc++.h>
using namespace std;
int a[1001];
int main(){
    int n,i,big=-1,small=11,sum=0;
    cin>>n;
    for (i=0;i<n;i++){
        cin>>a[i];
        if (a[i]>big) big=a[i];
        if (a[i]<small) small=a[i];
    }
    for (i=0;i<n;i++){
        if (a[i]==big){
            a[i]=0;
            big=-1;
        }
        if (a[i]==small){
            a[i]=0;
            small=11;
        }
    }
    for (i=0;i<n;i++){
        sum+=a[i];
    }
    cout<<fixed<<setprecision(2)<<sum*1.0/(n-2);
}

@liuzicheng100 求关


by taojinqi123456 @ 2024-12-16 21:04:08

我的代码:

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,x1[10000],d=0,xiao=0;
    float cnt=0.00;
    cin>>x;
    for(int i=0;i<x;i++){
        cin>>x1[i];
        if(x1[i]>x1[d]) d=i;
        if(x1[i]<x1[xiao])  xiao=i;
        cnt+=x1[i];
    }
    cnt-=x1[d];
    cnt-=x1[xiao];
    cnt/=x-2;
    printf("%.2f",cnt);
    return 0;
}

|