运用c语言,和循环结构打印n行数字图形,n在1~15之间取值。例如,当n的值为4时,程序输出如下:
1
2 3
4 5 6
7 8 9 10
运用c语言,和循环结构打印n行数字图形,n在1~15之间取值。例如,当n的值为4时,程序输出如下:
1
2 3
4 5 6
7 8 9 10
#include <stdio.h>
int main(){
int n = 4;
int x = 1;
for(int i=1;i<=n;i++) {
for(int j=0;j<i;j++) {
printf("%d",x++);
}
printf("\n");
}
return 0;
}