问题及代码:
#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=-1;
LowScore=101;
SumScore=0;
for(i=1; i<=n; i++)
{
scanf("%lf",&score);
if(score>HighScore)
HighScore=score;
else if(score<LowScore)
LowScore=score;
SumScore+=score;
}
AverageScore=SumScore/n;
}
运行结果