题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
def func(x):
result = [ [0 for j in range(x-i)] for i in range(x)]
for i in range(len(result)):
result[i][0] = int(i * (i+1) / 2 + 1)
for j in range(1,len(result[i])):
result[i][j] = int(result[i][j-1] + i + j + 1)
return result
while True:
try:
a = int(input())
b = func(a)
for i in range(len(b)):
print(*b[i])
except:
break