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

6~12

5838267e0001f6a108131603.jpg
58382683000151b808531610.jpg
5838268d0001610310031605.jpg
怎么改。。大神帮忙

提问者:慕粉1473033290 2016-11-25 19:55

个回答

  • 越飞越高
    2016-11-27 20:20:43

    include <stdio.h>
    #define N 10
    void printScore(int score[]){
        int i;
     printf("\n");
     for(i=0;i<N;i++){
      printf("%d\t",score[i]);
     }
     printf("\n");
    }
    int getTotalScore(int score[]){
     int sum = 0;
     int i;
     for(i=0;i<N;i++){
      sum+=score[i];
     }
     return sum;
    }
    int getAvgScore(int score[]){
     return getTotalScore(score)/N;
    }
    int getMax(int score[]){
     int max = -1;
     int i;
     for(i=0;i<N;i++){
      if(score[i]>max){
       max = score[i];
      }
     }
     return max;
    }
    int getMin(int score[]){
     int min = 100;
     int i;
     for(i=0;i<N;i++){
      if(score[i]<min){
       min=score[i];
      }
     }
     return min;
    }
    void sort(int score[]){
     int i,j;
     for(i=N-2;i>=0;i--){
      for(j=0;j<=i;j++){
       if(score[j]<score[j+1]){
        int temp;
        temp = score[j];
        score[j] = score[j+1];
        score[j+1] = temp;
       }
      }
     }
     printScore(score);
    }
    int main()
    {
        int score[N]={67,98,75,63,82,79,81,91,66,84};
        int sum,avg,max,min;
         sum = getTotalScore(score);
         avg = getAvgScore(score);
         max = getMax(score);
      min = getMin(score);
        printf("总分是:%d\n",sum);
     printf("平均分是:%d\n",avg);
     printf("最高分是:%d\n",max);
     printf("最低分是:%d\n\n",min);
     printf("********成绩排名********\n");
     sort(score);
        return 0;
    }