大佬求助啊,为啥只有一个绿(c语言)

P5726 【深基4.习9】打分

G13460488251 @ 2022-09-20 18:08:25

# include <stdio.h>

int main(void)
{
    int n,i;
    int a[20];
    float sum = 0;
    float x;
    scanf("%d",&n);
    for (i = 0;i < n; ++i)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    int max = 0,min = 0;
    for (i = 0;i < n;++i)
    {
        if(a[i] > a[max])
        max = i;
        if(a[i] < a[min])
        min = i;
    }
    x = (sum-a[max]-a[min])/(n-2);
    printf("%.2f",x);
    return 0;

}

by WA_sir @ 2022-09-20 18:25:27

@G13460488251

min初始值不应该是0,因为在没有0的情况下,1-10分都没他小。

改:

int max=0,min=1;

by AAA404 @ 2022-09-20 19:08:58

@sunreturn 他的max和min是下标


by Francais_Drake @ 2022-09-20 19:17:35

题面上不是有

\Huge\boldsymbol{n\le 1000}


by Francais_Drake @ 2022-09-20 19:18:00

@G13460488251


by G13460488251 @ 2022-09-20 22:02:22

@Francais_Drake 这啥意思呀


by G13460488251 @ 2022-09-20 22:02:44

@wztony2022 是吗


by WA_sir @ 2022-09-21 20:36:41

@G13460488251

Francais_Drake 是对的,数组开大一点,例如[1011]。

另外,你先试试。


by G13460488251 @ 2022-09-22 16:50:43

@wztony2022 绿了绿了,谢谢大佬


|