题解 | #蛇形矩阵#
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
n = int(input()) for i in range(n): for j in range(n-i): if j == n-i-1: print((i+j+1)*(i+j+2)//2 - i) else: print((i+j+1)*(i+j+2)//2 - i,end = ' ')
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
n = int(input()) for i in range(n): for j in range(n-i): if j == n-i-1: print((i+j+1)*(i+j+2)//2 - i) else: print((i+j+1)*(i+j+2)//2 - i,end = ' ')
相关推荐