为什么有时候运行成功,有时候又运行失败?
#include <stdio.h>
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
int i,j;
int sum=0;
int highScore;
int lowScore;
float average;
printf("---没排序---\n");
for(i=0;i<=9;i++)
{
printf("%d ",score[i]);
}
printf("\n");
i=0;
for(i=0;i<10;i++)
{
sum+=score[i];
for(j=0;j<10;j++)
{
if(score[j]<score[j+1])
{
int c;
c=score[j+1];
score[j+1]=score[j];
score[j]=c;
}
}
}
i=0;
average=sum/10;
highScore=score[0];
lowScore=score[9];
printf("---排序后---\n");
for(i=0;i<=9;i++)
{
printf("%d ",score[i]);
}
printf("\n");
printf("总分为:%d 平均分为:%.2f\n",sum,average);
printf("最高分为:%d 最低分为:%d",highScore,lowScore);
return 0;
}