第十三周:C语言:学生成绩

来源:互联网 发布:上传淘宝图片尺寸 编辑:程序博客网 时间:2024/04/25 16:00

问题:对学生成绩进行处理

代码:

/*烟台大学计算机学院  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;}

运行截图:


0 0