题解 | #蛇形矩阵#
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e?tpId=37&tqId=21258&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
N=int(input())
ls=[]
n=0#共n个数字
for i in range(1,N+1):
n+=i
for i in range(1,N+1):
a=[]
for j in range(i*(i-1)//2+1,i*(i-1)//2+1+i):
a.append(j)
ls.append(a)
ls_2=[]
for i in range(1,N+1):
b=[]
for item in ls:
if len(item)>=i:
b.append(item[-i])
ls_2.append(b)
for item in ls_2:
for i in item:
print(i,end=' ')
print()