#include <stdio.h>
int main()
{
int score,max,min,sum=0,num=0;
double ave=0;
printf("请输入若干学生的成绩,输入负数时结束:");
scanf("%d",&score);
max=min=score;
while(score>=0)
{
num++;
sum+=score;
if(max<score) /*求最高分*/
max=score;
if(min>score) /*求最低分*/
min=score;
scanf("%d",&score);
}
ave=sum*1.0/num;
printf("最高分为%d,最低分为%d,总分为%d,总共有%d个学生成绩,平均成绩为%lf",max,min,sum,num,ave);
}
从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩和学生总成绩平均成绩和学生数,当输入负数时结束
最新推荐文章于 2024-05-31 11:10:23 发布