#include <stdio.h>
#define N 10
//打印成绩
void printScore(int score[])
{
int i;
printf("\n");
for (i=0;i<10;i++)
{
printf("%d ",score[i]);
}
printf("\n");
}
//总分
int getSum(int score[])
{
int sum = 0;
int i;
for (i=0;i<N;i++)
{
sum += score[i];
}
printf("%d\n",score[i]);
return sum;
}
//平均分
int getAvg(int score[])
{
return getSum(score)/N;
}
//最高分
int getMax(int score[])
{
int Max = -1;
int i;
for (i=0;i<N;i++)
{
if (score[i]>Max)
{
Max = score[i];
}
}
return Max;
}
//最低分
int getMin(int score[])
{
int Min = 101;
int i;
for (i=0;i<N;i++)
{
if (score[i]<Min)
{
Min = score[i];
}
}
return Min;
}
//降序排序
void sort(int score[])
{
int temp = 0;
int i,j;
for (i=N-2;i>=0;i--)
{
if (score[j]>score[j+1])
{
temp = score[j];
score[j] = score[j+1];
score[j+1] = temp;
}
}
printScore(score);
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
int sum,avg,max,min;
sum = getSum(score);
avg = getAvg(score);
max = getMax(score);
min = getMin(score);
printf("总分是:%d\n",sum);
printf("平均分是:%d\n",avg);
printf("最高分是:%d\n",max);
printf("最低分是:%d\n",min);
printf("----------成绩排名---------\n");
sort(score);
return 0;
}