摘要:
谢尔宾斯基三角形使用了三路递归算法,从一个大三角形开始,通过连接每一个边的中点,将大三角型分为四个三角形,然后忽略中间的三角形,依次对其余三个三角形执行上述操作。 运行效果: 源代码: 1 import turtle 2 3 4 def draw_triangle(points, color, my 阅读全文
posted @ 2019-11-09 22:03
孤云jh
阅读(2261)
评论(0)
推荐(0)
摘要:
运行效果: 源代码: 1 # -*- coding:utf-8 -*- 2 ##汉诺塔游戏开始 3 _times=0 #用于统计移动次数 4 def hannuota(nlist,mfrom,mpass,mto): 5 global _times 6 n=len(nlist) 7 if n==1: 阅读全文
posted @ 2019-11-09 21:59
孤云jh
阅读(530)
评论(0)
推荐(0)
摘要:
运行效果: 可在函数中指定阶层数,输出对应的杨辉三角 源代码如下: 1 # -*-coding:utf-8 -*- 2 ''' 3 chapter4_do.py 4 函数yanghui(n)用于输出n阶杨辉三角 5 ''' 6 def yanghui(n): 7 if not str(n).isde 阅读全文
posted @ 2019-11-09 21:56
孤云jh
阅读(2049)
评论(0)
推荐(0)

浙公网安备 33010602011771号