第十三周:C语言:学生成绩
问题:对学生成绩进行处理
代码:
/*
烟台大学计算机学院 2016
作者:闫春相
完成日期:2016年12月15日
版本号:V1.0
*/
#include <stdio.h>
double HighScore; /*全局变量,最高分*/
double LowScore; /*全局变量,最低分*/
double SumScore; /*全局变量,总分*/
double AverageScore; /*全局变量,平均分*/
void calcscore(int n); /*函数声明*/
int main()
{
int n;
scanf("%d",&n);
calcscore(n);
printf("%g %g %g %g\n",HighScore,LowScore,SumScore,AverageScore);
return 0;
}
void calcscore(int n)
{
int i;
double score;
HighScore=0,LowScore=100,SumScore=0;
for(i=0;i<n;i++)
{
scanf("%lf",&score);
if(score>=HighScore)
HighScore=score;
if(score<=LowScore)
LowScore=score;
SumScore+=score;
}
AverageScore=SumScore/n;
}
运行截图:
还没有评论,来说两句吧...