作者:李忠林
时间:2016.11.28
代码:
#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 s;
HighScore=-1;
LowScore=100;
AverageScore=0;
for(i=0; i<n; i++)
{
scanf("%lf",&s);
if(s>HighScore)
{
HighScore=s;
}
if(s<LowScore)
{
LowScore=s;
}
SumScore+=s;
}
AverageScore=SumScore/n;
return;
}
运行结果: