Commit 6f367c68 by BellCodeEditor

save project

parent 80f11f3c
Showing with 23 additions and 2 deletions
def q():
s=[0.01,0.02,0.05,0.1,0.2,0.5,1.0]
while True:
try:
w=float(input("请输入要找的零钱:"))
if w<=0:
print("请输入正数")
else:
break
except:
print("请输入小数")
i=len(s)-1
while i>=0:
if w >=s[i]:
n=int(w/s[i])
w=float("{:.2f}".format(w-n*s[i]))
print("找了{}个{}元硬币".format(n,s[i]))
i-=1
q()
...@@ -12,4 +12,4 @@ def new_input(): ...@@ -12,4 +12,4 @@ def new_input():
else: else:
total.append(unit) total.append(unit)
print(total) print(total)
new_input() new_input()
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment