摘要: #汉诺塔问题 count=0 def hannuo(n,scr,dst,mid): global count if n==1: print("{}:{}->{}".format(1,scr,dst)) count+=1 else: hannuo(n-1,scr,mid,dst) print("{}: 阅读全文
posted @ 2020-03-30 21:28 sumuwwx 阅读(74) 评论(0) 推荐(0) 编辑
摘要: #文本进度条 import time s=10 print(" 执行开始 ") for i in range(s+1): a='*'*i b='.'*(s-i) c=(i/s)*100 print("{:^3.0f}%[{}->{}]".format(c,a,b)) time.sleep(0.1) 阅读全文
posted @ 2020-03-30 21:09 sumuwwx 阅读(96) 评论(0) 推荐(0) 编辑
摘要: #圆周率计算公式法 p=0 n=100 for k in range(n): p+=1/pow(16,k)*(4/(8*k+1)-2/(8*k+4)-1/(8*k+5)-1/(8*k+6)) print("{}".format(p)) #圆周率计算蒙特卡罗法 from random import r 阅读全文
posted @ 2020-03-30 19:27 sumuwwx 阅读(830) 评论(0) 推荐(0) 编辑