c语言编:输入某班学生某门课的成绩,统计平均分,最高分和不及格人数

2025-04-06 06:51:09
推荐回答(1个)
回答1:

#include

int main()

{int x,n=0,max=0,min=999,fail=0,sum=0,a[100];

while(1)

{scanf("%d",&x);

if(x<0)break;

a[n++]=x;

sum+=x;

if(x>max)max=x;

else if(x

if(x<60)fail++;  

}

printf("最高分=%d\n",max);

printf("最低分=%d\n",min);

printf("不及格人数=%d\n",fail);

printf("平均分=%.2f\n",(float)sum/n);

return 0;

}