不知道哪里錯了
#include <stdio.h>
int main()
{
? ? int score[10]={67,98,75,63,82,79,81,91,66,84};
? ? int i,j;
? ? int temp;
? ? for(i=9;i<=0;i--)
? ? {
? ? ? ? for(j=0;j<=i;j++)
? ? ? ? {
? ? ? ? if(score[j]<score[j+1])
? ? ? ? ? ? {
? ? ? ? ? ? ? ? temp=score[j];
? ? ? ? ? ? ? ? score[j]=score[j+1];
? ? ? ? ? ? ? ? score[j+1]=temp;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ??
? ? }
? ? for(i=0;i<10;i++)
? ? {
? ? ? ? printf("%d\n",score[i]);
? ? }
? ? ? ? return(0);
}
2016-12-27
第一層for循環(huán)的i<=0 改為i>=0
2016-12-27
for循環(huán)里面的score[i+1]錯了,當(dāng)i=9的時候i+1=10,score[10]數(shù)組下標(biāo)越界