题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
分享下我的思路,基本就是两个for横向和竖向便利
然后就是找规律了
while True: try: a = int(input()) num = 0 # 竖向遍历 for j in range(a): num = num + j row = num for i in range(j,a): row = row+1+i # 横向每行输出 print(row - j,end=" ") print("") except: break