输出:
1
12
123
1234
12345
1234
123
12
1
for i in range(1,6):
for j in range(1,i+1):
print(j,end=" ")
print()
for i in range(4,0,-1):
for j in range(1,i+1):
print(j,end=" ")
print()
输出:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
for i in range(1,5):
a=''
for j in range(1,i+1):
a+=str(j)
b=a+a[-2::-1]
print(" "*((5-i)*2),' '.join(b))
输出:
0
12
345
6789
a=0
b=1
for i in range(1,5):
for j in range(a,b):
print(j,end='')
print()
a=a+i
b=b+i+1