為什么排序變成這樣?
int DownM(int score[])
{
? ? int i,j,temp;
? ? for(i=8;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;
? ? ? ? }
? ? }
? ? ?printf("TheStudentScoreDownIs\n");
? ? for(i=0;i<10;i++)
? ? {
? ? ? ? if(i!=9)
? ? ? ? {
? ? ? ? ? ? printf("%d\n",score[i]);
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? printf("%d",score[i]);
? ? ? ? }
? ? }
}
排序:
2020-02-17
你把遍歷里面的if里的執(zhí)行語句多加對{}括起來就好了