#include <stdio.h>
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
int n,sum;
for(n=0;n<9;n++)
{
sum+=score[n];
}
printf("总分为%d\n",sum);
int index,i,j;
for(n=0;n<9;n++)
{
for(j=9;j>=0;j--)
{
if(score[i]<score[i+1])
{
index=score[i];
score[i]=score[i+1];
score[i+1]=index;
}
}
}
printf("成绩降序排列:");
for(n=0;n<9;n++)
printf("%d,",score[n]);
printf("最高分为%d\n",score[0]);
printf("最低分为%d\n",score[9]);
int s;
s=sum/10;
printf("平均分为%c\n",s);
return 0;
}
你开头就错了,sum没初始化,
求和的时候n<=9或n<10。你写的n<9(这样少算一位)
冒泡排序你再好好看吧