請大佬解釋!
#include <stdio.h>
#define N 10
void Zong(int score[])
{
??? int sum=0;
??? for(int i=0;i<10;i++)
??? {
??????? sum+=score[i];
??? }
??? printf("總分為:%d\n",sum);
??? printf("平均分為:%d\n",sum/10);
}
void Jiang(int score[])
{
??? int temp;
??? for(int i=8;i<10;i--)
??? {
??????? for(int j=0;j<i;j++)
??????? {
??????????? if(score[j]<score[j+1])
??????????? {
??????????????? temp=score[j];
??????????????? score[j]=score[j+1];
??????????????? score[j+1]=temp;
??????????? }
??????? }
??? }
??? printf("降序排序?yàn)椋?);
??? for(int i=0;i<10;i++)
??? {
??????? printf("%d? ",score[i]);
??? }
??? printf("最高分為:%d\n",score[0]);
??? printf("最低分為:%d\n",score[9]);
}
int main()
{
??? int score[N]={67,98,75,63,82,79,81,91,66,84};
??? Zong(score);
??? Jiang(score);
??? return 0;
}
為什么運(yùn)行結(jié)果是:timeout
2018-08-04
? for(int i=8;i<10;i--)
這里 不對吧 ?i是遞減 判斷條件應(yīng)該是 >0 ?另外 i 應(yīng)該從9開始?