自由尋覓快樂別人從沒法感受

0%

C语言学习第五章T2

题目:编程输出特定的数字

1 0 0 0 0 0
2 1 0 0 0 0
3 2 1 0 0 0
4 3 2 1 0 0
5 4 3 2 1 0
6 5 4 3 2 1

主要代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# include <stdio.h>
int main (void)
{
int a[6]={1,0,0,0,0,0},i,x,y;
for (i=0;i<6;i++)
{
for (x=0;x<6;x++)
{
printf("%4d",a[x]);
}
printf("\n");
for (y=0;y<=i+1;y++)
{
a[y]=a[y]+1;
}
}
return 0;
}

运行结果: