为什么输出两个sum,可以怎么改进呢
#include <stdio.h>
#define N 11
int Sum(int score[])
{
int sum=0;
for(int i=0;i<10;i++)
sum+=score[i];
printf("sum=%d\n",sum);
return sum;
}
int Max(int score[])
{
int max=score[0];;
for(int i=1;i<10;i++)
{
if(max<=score[i])
{
max=score[i];
printf("max=%d\n",max);
}
}
return max;
}
int Min(int score[])
{
int min=score[0];;
for(int i=1;i<10;i++)
{
if(min>=score[i])
{
min=score[i];
printf("min=%d\n",min);
}
}
return min;
}
double Avg(int score[])
{
double avg=Sum(score)/10.0;
printf("avg=%f\n",avg);
return avg;
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
Sum(score);
Max(score);
Min(score);
Avg(score);
return 0;
}