美文网首页python学习笔记
python练手_61-杨辉三角

python练手_61-杨辉三角

作者: 学子CH | 来源:发表于2019-02-17 17:50 被阅读0次
# -*- coding:utf-8 -*-
# @Author: CH
"""
@project: python study
@time:2019/1/7-23:54
@file_name:【程序61】杨辉三角.py
@IDE:PyCharm 
@else: DO NOT STOP STUDYING!!!
"""
# 题目 打印出杨辉三角形前十行。
#
# 程序分析 无
def generate(numRows):
    r = [[1]]
    for i in range(1,numRows):
        r.append(list(map(lambda x,y:x+y, [0]+r[-1],r[-1]+[0])))
    return r[:numRows]
a=generate(10)
for i in a:
    print(i)

相关文章

网友评论

    本文标题:python练手_61-杨辉三角

    本文链接:https://www.haomeiwen.com/subject/gaameqtx.html