要求输出如下
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4
0 1 2 3
0 1 2
0 1
0
要求输出如下
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4
0 1 2 3
0 1 2
0 1
0
#include<stdio.h>
void main()
{
const int row=5;
int r;
int j;
//打印上半行
for(r=0;r<=row;++r)
{
for( j=0;j<=r;++j)
{
printf("%d ",j);
}
printf("\n");
}
//打印下半行
for(r=row-1;r>=0;--r)
{
for(j=0;j<=r;++j)
{
printf("%d ",j);
}
printf("\n");
}
getchar();
}
vb的:
Private Sub Form_Click() For i = 0 To 5 For j = 0 To i Print j & Space(2); Next j Print Next i For i = 4 To 0 Step -1 For j = 0 To i Print j & Space(2); Next j Print Next i End Sub