大家好,有些VAR是葡萄牙语的对不起,所以我想展示一下,在atm机上,你会和不会得到多少威奇类型的钞票:例如:
IN: $123,45
OUT:1 OF $100 BILL, 0 OF $50 BILL, 1 OF $20 BILL, 0 OF $10 BILL and etc.
这是我到目前为止所做的,但我不能做的法案,将不会在自动取款机请帮助
r = 0
print('='*20)
print('{:^20}'.format('CAIXA ELETRÔNICO'))
print('{:^20}'.format(' Banco do Romeu '))
print('='*20)
caixa = float(input('Qual será o valor sacado? '))
total = caixa
ced = 100
totalced = 0
while True:
if total >= ced:
total = total - ced
totalced += 1
else:
if totalced > 0:
print(f'{totalced} notas(s) de R${ced}')
elif ced == 100:
ced = 50
elif ced == 50:
ced = 20
elif ced == 20:
ced = 10
elif ced == 10:
ced = 5
elif ced == 5:
ced = 2
elif ced == 2:
ced = 1
elif ced == 1:
ced = 0.50
elif ced == 0.50:
ced = 0.25
elif ced == 0.25:
ced = 0.10
elif ced == 0.10:
ced = 0.05
elif ced == 0.05:
ced = 0.01
totalced = 0
if total == 0:
break
可以从初始值中减去值。 变量valor是初始值
你可以做一个贪婪的方法,试着减去价值最高的账单,并记下你从每张账单中减去的次数。例如:
423,45岁
从100美元开始,你可以减去4倍。你只剩下23,45了。 然后你继续付50美元。你不能从23,45减去50美元,所以你要付次高的20美元。 你可以从23,45减去一美元20,剩下的是,45
你继续数到不能再减法为止。然后你打印出每张账单的减法数。希望这有道理
相关问题 更多 >
编程相关推荐