摘要:
#汉诺塔问题 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("{}: 阅读全文
摘要:
#文本进度条 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) 阅读全文
摘要:
#圆周率计算公式法 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 阅读全文