题解 | #蛇形矩阵#

蛇形矩阵

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

# -*-coding:utf-8-*-

while True:
    try:
        input_i = int(input())
        i_list = []
        input_j =input_i
        init_num = 1
        for ii in range(0,input_i):
            init_num = init_num + ii
            #print(init_num)
            x = 0
            for jj in range(0,input_j):
                if jj ==0:
                    print(init_num,end=" ")
                    x = init_num
                else:
                    x = x+jj+ii+1
                    print(x,end=" ")
            input_j = input_j -1
            print()

    except:
        break

全部评论

相关推荐

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