#include <stdio.h>
#define N 10
void score_Sum(int score[],int length);
void score_Max(int score[],int length);
void score_Min(int score[],int length);
void score_Ave(int score[],int length);
void score_Set(int score[],int length);
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
score_Sum(score,N);
score_Max(score,N);
score_Min(score,N);
score_Ave(score,N);
score_Set(score,N);
return 0;
}
//考试成绩的总分
void score_Sum(int score[],int length)
{
int sum=0;
for(int i=0;i<length;i++)
sum += score[i];
printf("考试的总分是:\t%d。\n",sum);
}
//考试的最高分
void score_Max(int score[],int length)
{
int max=score[0];
for(int i=1;i<length;i++)
{
if(score[i] > max)
max = score[i];
}
printf("考试的最高分是:\t%d。\n",max);
}
//考试的最低分
void score_Min(int score[],int length)
{
int min=score[0];
for(int i=1;i<length;i++)
{
if(score[i] < min)
min = score[i];
}
printf("考试的最低分是:\t%d。\n",min);
}
//考试的平均分
void score_Ave(int score[],int length)
{
int sum=0;
float ave=0;
for(int i=0;i<length;i++)
sum += score[i];
ave = sum * 1.0 / length;
printf("考试的平均分是:\t%.2f。\n",ave);
}
//考试成绩降序排列
void score_Set(int score[],int length)
{
int temp;
for(int i=length-2;i>0;i--)
for(int j=0;j<=i;j++)
{
if(score[j] < score[j+1])
{
temp = score[j];
score[j] = score[j+1];
score[j+1] = temp;
}
}
printf("考试成绩降序排列为:\n");
for(int i=0;i<length;i++)
{
printf("%d",score[i]);
if(i == length-1)
printf("。\n");
else
printf(", ");
}
}