杨辉三角生成器
开发的算法(def PascalTriangle(limit:int) -> list:
"""
limit
限制生成的层数
提示:如果你想无限生成杨辉三家的话,可使用下面这个
"""
Result =
for times in range(int(limit)):
yield Result
_Product =
for i in range(0, len(Result)):
if i + 1 > len(Result) - 1: #判断是否完成
_Product.append(Result)
break
else:
_Product.append(Result + Result)
Result = _Product
def PascalTriangle_Loop() -> list:
Result =
while True:
yield Result
_Product =
for i in range(0, len(Result)):
if i + 1 > len(Result) - 1: #判断是否完成
_Product.append(Result)
break
else:
_Product.append(Result + Result)
Result = _Product 感谢分享 有错别字(6{:10_249:} 感谢感谢!! 谢谢分享
{:10_316:}感谢分享
页:
[1]