问答详情
源自:6-12 综合练习

为什么一直报错呢?哪里错了呀?

#include <stdio.h>

int decending(int score[])
{int i;
   int j;
   int sum=0;
   
    for(i=9;i>0;i--)
    {
      for(j=0;j<9;j++) 
      {
          if(score[j]>score[j+1])
          {
          int temp=score[j];
          score[j]=score[j+1];
          score[j+1]=temp;
          }
      }
    }
    printf("the decending order is\n");
    for(i=0;i<10;i++)
    {
        printf("%d",score[i]);
        sum=sum+score[i];
    }
  
    int aver=sum/10;
      printf("\nthe lowest score is %d\n",score[0]);
      printf("the highest score is %d\n",score[9]);
      printf("the average score is %d\n",aver);
      printf("the total score is %d\n", sum);
    return 0;   
}
int main()
{
   
    int score[N]={67,98,75,63,82,79,81,91,66,84};
    decending(score);
    return 0;
}


提问者:慕用4518114 2019-06-16 00:15

个回答

  • 纵流沙
    2019-06-25 17:06:29
    已采纳

    int main()里面 int score[N]={67,98,75,63,82,79,81,91,66,84}; 这一句N没有定义,建议把N改为10,或者使用宏定义 #define N 10

  • 慕田峪9245785
    2019-06-16 17:28:57

    i>=0

    j<i