请问为什么我这个程序出来的最小数字后面还会有个“,”呢?并且不会出现换行?

来源:6-12 综合练习

qq_刘_20

2017-10-23 21:04

#include <stdio.h>

int main()

{

    int score[10]={67,98,75,63,82,79,81,91,66,84};

    int i,j,k,sum,ave;

     for(j=8;j>=0;j--)

    {

    for(i=0;i<9;i++)

    {

        if(score[i]<score[i+1])

        {

            int temp;

        temp=score[i+1];

        score[i+1]=score[i];

        score[i]=temp;

            

        }

         

    }

        

    }for(j=0;j<9;j++)

    {

       

        if(j!=9)

        {

            printf("%d,",score[j]);

        }

        else

        {

            printf("%d\n",score[j]);

        }

    

   

    }

    for(k=0;k<9;k++)

    {

        int k=0;

        sum=score[k]+sum;

        

    }

    ave=sum/10;

    printf("\n总分是%d\n平均分是%d\n",sum,ave);

    printf("最高分是%d\n最低分是%d\n",score[0],score[9]);

    return 0;

}


写回答 关注

1回答

  • 一休哥的爱
    2020-01-24 16:28:49

     printf("%d,",score[j]); 你的这行代码写错了,应该是 printf("%d\n",score[j]);

C语言入门

C语言入门视频教程,带你进入编程世界的必修课-C语言

928347 学习 · 21550 问题

查看课程

相似问题