为什么会是RE?

P5726 【深基4.习9】打分

sanammm @ 2022-10-17 20:07:47

#include<stdio.h>
int main()
{
    int n,a,max=10,min=0,cnt=0;
    scanf("%d",&n);
    int s=0;
    for (int i=0;i<n;i++)
    {
        scanf("%d",a);
        if (a<min) min=a;
        if (a>max) max=a;
        cnt++;
        s+=a;
    }
    float ave;
    ave=(s-max-min)*1.0/(cnt-2)*1.0;
    printf("%.2f",ave);
    return 0;
}

by wzch @ 2022-10-17 20:10:30

第九行scanf("%d",&a);


by sunyizhe @ 2022-10-17 20:26:38

将第九行改为 scanf("%d",&a);

scanf 需要传地址


by tang_mx @ 2022-10-17 20:36:18

第九行应为scanf("%d",&a); 记住了以后输入别忘了加& 记住了以后输入别忘了加& 记住了以后输入别忘了加& (重要的事情说三遍


|