题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
while 1: try: n = int(input()) # 创建N行列表 li = [[] for _ in range(n)] # 计算出最大值 m = 0 for i in range(n+1): m+=i # 按列表行号填充 for i in range(n): for j in range(n-i): li[j].append(m) m-=1 # 遍历输出 for i in li: i = i[::-1] print(*i) except: break