已编译正确代码,欢迎讨论交流!!
#include <stdio.h>
int GetTotal(int score[])
{
int total=0,i;
for(i=0;i<=9;i++)
{
total+=score[i];
}
return(total);
}
int GetMax(int score[])
{
int max,i;
max=score[0];
for(i=0;i<=9;i++)
{
if(score[i]>max)
max=score[i];
}
return max;
}
int GetMin(int score[])
{
int min,i;
min=score[0];
for(i=0;i<=9;i++)
{
if(score[i]<min)
min=score[i];
}
return min;
}
double Getaverage(int score[])
{
int avg=0;
int i;
for(i=0;i<=9;i++)
{
avg+=score[i];
}
return avg/10;
}
void sort_low(int score[])
{
int i,j,t;
for(j=0;j<9;j++)
{
for(i=0;i<9-j;i++)
{
if(score[i+1]<score[i])
{
t=score[i+1];
score[i+1]=score[i];
score[i]=t;
}
}
}
return;
}
int main()
{
int i;
int score[10]={67,98,75,63,82,79,81,91,66,84};
printf("班级总分为%d\n",GetTotal(score));
printf("班级的最高分为%d\n",GetMax(score));
printf("班级的最低分为%d\n",GetMin(score));
printf("班级的平均分为%.6f\n",Getaverage(score));
sort_low(score);
printf("考试成绩降序排序为:\n");
for(i=0;i<=9;i++)
{
printf("%5d",score[i]);
}
return 0;
}