#include <stdio.h>
int sumfun(int score[]);
float average(int score[]);
void order(int score[]);
int maxfun(int socre[]);
int minfun(int score[]);
int main()
{
int score[]={67,98,75,63,82,79,81,91,66,84};
int sum = sumfun(score);
float aver = average(score);
int max = maxfun(score);
int min = minfun(score);
printf("Score array:\n");
int i;
for(i = 0; i<10; i++)
{
if(i == 9)
{
printf("%d\n",score[i] );
}
else
{
printf("%d," ,score[i]);
}
}
printf("To order:\n");
order(score);
printf("The max:%d\n", max);
printf("The min:%d\n", min);
printf("The sum:%d\n", sum);
printf("The averge:%.2f\n", aver);
return 0;
}
int sumfun(int score[])
{
int sum, i;
for(i=0; i<10; i++)
{
sum += score[i];
}
return sum;
}
float average(int score[])
{
float ave = sumfun(score)/10;
return ave;
}
void order(int score[])
{
int i, j;
for(i=9;i>0;i-- )
{
for(j=0; j<i;j++)
{
if(score[j]<score[j+1])
{
int temp = score[j];
score[j] = score[j+1];
score[j+1] = temp;
}
}
}
//printf("array score then:\n");
for(i=0;i<10;i++)
{
if(i==9)
{
printf("%d\n",score[i]);
}
else
{
printf("%d,",score[i]);
}
}
}
int minfun(int score[])
{
int i;
int min = score[0];
for(i=1; i<10;i++)
{
if(min > score[i])
{
min = score[i];
}
}
return min;
}
int maxfun(int score[])
{
int i;
int max = score[0];
for(i=1; i<10;i++)
{
if(max < score[i])
{
max = score[i];
}
}
return max;
}