每次增加都是在原有的基础上增加。
while True:
try:
size = int(input())
base = [[0 for i in range(size)] for j in range(size)]
count = 1
for index in range(size):
x = index
for i in range(x, -1, -1):
base[i][x-i] = count
count += 1
res = ''
for i in base:
for j in i:
if j != 0:
res = res + str(j) + ' '
print(res.strip())
res = ''
except Exception as e:
print(e)
break5 1 3 6 10 15 2 5 9 14 4 8 13 7 12 11

京公网安备 11010502036488号