题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
from itertools import accumulate
def func(s):
l=list(accumulate(range(1,s+1)))
ll =[]
lll = []
lll.append(l)
for i in range(s):
if i > 0:
ll=list(map(lambda x,y:x+y,lll[i-1],list(range(i,s))))
lll.append(ll)
return lll
while True:
try:
s = int(input())
for i in func(s):
print(*i)
except:
break