#coding=gbk #定義零錢種類 moneycount=[100,50,20,10,5,1] def getMax(x): m=[] while True: for i in moneycount: if i<=x: x-=i m.append(i) break if x<1: break return m a=getMax(298) print(a)
練習一下算法
#coding=gbk #定義零錢種類 moneycount=[100,50,20,10,5,1] def getMax(x): m=[] while True: for i in moneycount: if i<=x: x-=i m.append(i) break if x<1: break return m a=getMax(298) print(a)
練習一下算法
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。