C语言菜鸟,问题求解
输出如下:1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
.................................
#include<stdio.h> int main() { int i, j, n, m = 1; scanf_s("%d", &n); //方便调试,不是必须 if (n < 15) n = 15; for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { printf("%d", m++); printf(" "); if (m > n) break; } printf("\n"); if (m > n) break; } return 0; }
[此贴子已经被作者于2018-12-19 21:14编辑过]