题解 | #蛇形矩阵#

蛇形矩阵

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

from itertools import accumulate
def func(s):
    l=list(accumulate(range(1,s+1)))
    ll =[]
    lll = []
    lll.append(l)
    for i in range(s):
        if i > 0:
            ll=list(map(lambda x,y:x+y,lll[i-1],list(range(i,s))))
            lll.append(ll)
    return lll
while True:
    try:
        s = int(input())
        for i in func(s):
            print(*i)
    except:
        break
        
        
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务