Remove white space at the end of the output in C

后端 未结 6 1297
离开以前
离开以前 2021-01-27 06:59

The following code is for printing the elements of a matrix in spiral order. The program works fine. The problem, however, is that the online compiler against which I\'m checkin

6条回答
  •  温柔的废话
    2021-01-27 07:59

    You can put an if condition in your for loops

    for (i = l; i < n; ++i)
    {
            printf("%d", a[k][i]);
            if(i < n-1)
                printf(" ");
    }
    

提交回复
热议问题