求一个班学生的数学平均成绩、最高分、最低分
/* 功能:求一个班学生的数学平均成绩、最高分、最低分 日期:2013-05-08 */ #include <stdio.h> #include <stdlib.h> #include <math.h> int main(void) { int maths,maxMath,minMath,sum,i; float aveMatrh; printf(“请输入本班所有学生的成绩:n”); maxMath=0; minMath=maths; for(sum=0,i=0;maths>=0;i++) { scanf(“%d”,&maths); if (maths>=0) { maxMath=maxMath>maths?maxMath:maths; minMath=minMath<maths?minMath:maths; sum+=maths; } } aveMatrh=(float)sum / (float)(i-1); printf(“这个班学生的平均分为;%.1f,最高分为:%d,最低分为:%dn”,aveMatrh,maxMath,minMath); system(“pause”); return 0; }
Preview
除特别注明外,本站所有文章均为 Windcoder网 原创,转载请注明出处来自: average-math-scores-of-students-in-one-class-and-the-highest-and-lowest-scores
Loading comments...

Preview
No Data