/*学生成绩的平均分及其及格人数*/ #include<stdio.h> int main(void) { int count,num,n;/*num记录输入得个数,count记录不及格的人数*/ double grade,total;/*分别存放成绩、成绩总和*/ num=0; total=0; count=0; printf("Enter n:");/*输入提示*/ scanf("%d",&n); printf("Enter grades:");/*输入提示*/ scanf("%lf",&grade); while(grade>=0){ total=total+grade;/*累加成绩*/ num++;/*计数*/ if(grade>60) count++; scanf("%lf",&grade);/*读入一个新数据为下次循环做准备*/ } if(num!=0){ printf("Grade average is%.2f ",total/num); printf("Number of success is %d ",count); } else printf("Grade average is0 "); return 0; }