『代码』··By/蜜汁炒酸奶

求一个班学生的数学平均成绩、最高分、最低分

/* 功能:求一个班学生的数学平均成绩、最高分、最低分 日期: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; }

预览
Loading comments...
0 条评论

暂无数据

example
预览