zl程序教程

您现在的位置是:首页 >  Python

当前栏目

python编写程序统计一元人民币换成一分、两分和五分的所有兑换方案个数(用while循环)

2023-04-18 14:04:35 时间

a = int(input("输入钱数(单位:元)"))
e=a*100
count=0
i=-1
while i <(e//5+1):
    i+=1
    b=(e-5*i)//2+1
    g=-1    
    while g<b:
        g+=1
        c=e-5*i-g*2+1
        h=-1
        while h<c:
            h+=1
            if 5*i+g*2+h==e:
                count+=1
print(count)