输出对角线(空格控制)

#include <stdio.h>

int main(void)
{
    int i, j;
    int x;    

    printf("hello world
");
    scanf("%d", &x);

    for (i = 1; i <= x; i++) {
        for (j = 1; j < i; j++)
            putchar(' ');    
        printf("%d
", i % 10);
    }

    return 0;
}

输出

hello world
8
1
 2
  3
   4
    5
     6
      7
       8
原文地址:https://www.cnblogs.com/sea-stream/p/11037603.html