#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)
练习一下算法