题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
这种打印矩阵的要先观察发现规律,
import sys
for line in sys.stdin:
N=int(line.strip())
res=[]
for i in range(N):
if i==0:
res=[(e+2)*(e+1)//2 for e in range(N)]
else:
res=[e-1 for e in res[1:]]
# print(res) #其实到这里核心代码就结束了
for t in res:
print(t,end=" ")
print()