#include <stdio.h>
//计算考试总分
int allScore(int score[])
{
int sum=0;
int i;
for(i=0;i<N;i++)
{
sum+=score[i];
printf("总分是: %d\n",sum);
}
return sum;
}
//最高分
int maxScore(int score[])
{
int max=-1;
int i;
for(i=0;i<N;i++)
{
if(score[i]>max)
{
max=score[i];
printf("最高分是: %d\n",max);
}
}
return max;
}
//最低分
int minScore(int score[])
{
int min=100;
int i;
for(i=0;i<N;i++)
{
if(score[i]<min)
{
min=score[i];
printf("最低分是: %d\n",min);
}
}
return min;
}
//平均分
int getAvgScore(int score[])
{
int avg=0;
avg+=allScore(score)/N;
printf("平均分是: %d\n",avg);
return avg;
}
//考试成绩降序排序
int sortScore(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;
temp=score[j];
score[j]=score[j+1];
score[j+1]=temp;
}
}
}
return score;
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
printf("%d\n",allScore(score),maxScore(score),minScore(score),getAvgScore(score));