作者:李忠林
時間: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;
}
運行結果: