求救:最新版答案,还是过不了

P5726 【深基4.习9】打分

Undertakers @ 2024-10-18 10:11:59

#include <stdio.h>
int main() {
    int i,n,min,max,sum;
    scanf("%d",&n);
    int score[n];
    for(i = 0; i < n; i++) {
        scanf("%d",&score[i]);
    }
    for(i = 0; i < n; i++) {
        sum+=score[i];
    }
    minmax(score,n,&min,&max);
    sum-=(min+max);
    double average=1.0*sum/(n-2);
    printf("%.2f",average);
    return 0;
}
int minmax(int score[],int len,int*min,int*max)
{
    int t;
    *max=*min=score[0];
    for(t=0; t<len; t++)
    {
        if(score[t]>*max) *max=score[t];
        if(score[t]<*min) *min=score[t];
    }
    return minmax;
}

by _th_tw_on_ @ 2024-10-18 10:47:06

@Undertakers sum 没赋初值


by Undertakers @ 2024-10-18 16:11:00

@_th_twon 过了,谢谢


|