第三章例3-3
/* 输入一批学生的成绩,计算平均分,并统计不及格成绩的学生人数 */ #include<stdio.h> int main(void) { int count,i,n; double grade,total; printf("Enter n:"); scanf_s("%d",&n); total=0; count=0; for(i=1;i<=n;i++){ printf("Enter grade#%d:",i); scanf_s("%lf",&grade); total=total+grade; if(grade<60){ count++; } } printf("Grade average=%.2f\n",total/n); printf("Number of failures=%d\n",count); return 0; }