题解 | #记票统计#

蛇形矩阵

http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e

while True:
    try:
        max=int(input())+1
        shuzhu1=[([1]*max)for i in range(max)]
        c=max+1
        for i in range(1,max):
            shuzhu1[i][1]=shuzhu1[i-1][1]+(i-1)
            ca=i+1
            c=c-1
            for j in range(2,c):
                shuzhu1[i][j]=shuzhu1[i][j-1]+ca
                ca+=1
                c=max+1
        for i in range(1,max):
            c=c-1
            for j in range(1,c):
                print(shuzhu1[i][j],end=" ")
            print("")
    except:
        break
全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务