#include <stdio.h>
#define N 10
int TotalScore(int score[]);
int MaxScore(int score[]);
int MinScore(int score[]);
int AverageScore(int score[]);
void OrderScore(int score[]);
void printScore(int score[])
{
int i;
printf("\n");
for(i=0;i<N;i++)
{
printf("%d ",score[i]);
}
printf("\n");
}
int TotalScore(int score[])
{
int i,sum=0;
for(i=0;i<=N;i++)
{
sum+=score[i];
}
return sum;
}
int AverageScore(int score[])
{
return TotalScore(score)/N;
}
int MaxScore(int score[])
{
int i,max=-1;
for(i=0;i<=N;i++)
{
if(max<score[i])
{
max=score[i];
}
}
return max;
}
int MinScore(int score[])
{
int i,min=100;
for(i=0;i<=N;i++)
{
if(min>score[i])
{
min=score[i];
}
}
return min;
}
void OrderScore(int score[])
{
int i,j,temp;
for(i=N-2;i>=0;i--)
{
for(j=0;j<=i;j++)
{
if(score[j]<score[j+1])
score[j]=temp;
score[j+1]=score[j];
score[j+1]=temp;
}
}
printScore(score);
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
int sum,max,min,aver,order;
sum=TotalScore(score);
max=MaxScore(score);
min=MinScore(score);
printf("考试总分是: %d\n",sum);
printf("考试最高分是: %d\n",max);
printf("考试最低分是: %d\n",min);
printf("考试平均分是: %d\n",aver);
printf("**********成绩排名**********");
OrderScore(score);
return 0;
}
慕移动9341187
相关分类