题解 | #蛇形矩阵#
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
n = int(input().strip()) o = [] for i in range(n): temp = [0] * (n - i) if i == 0: temp[0] = 1 else: temp[0] = o[i - 1][0] + i step = i + 2 for j in range(1, len(temp)): temp[j] = temp[j - 1]+step step += 1 o.append(temp) for t in o: for i in range(len(t)): if i != len(t) - 1: print(t[i], end=' ') else: print(t[i])