贪心算法 python

假设有4种硬币,面值分别为两角五分,一角,五分和一分。现在找给顾客六角三分,求拿出硬币个数最少的算法程序

s=[25,10,5,1]
n=63
count=0
while(n>0):
	for i in s:
		while(n>=i):
			n=n-i
			count=count+1
			
	print(count)
		

猜你喜欢

转载自blog.csdn.net/qq_36557525/article/details/80726173