Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 현태/거스름돈(for문).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
price = int(input())
change = 1000 - price
total_cnt = 0

coins = [500,100,50,10,5,1]

for coin in coins:
total_cnt += change // coin
change %= coin


print(total_cnt)
17 changes: 17 additions & 0 deletions 현태/거스름돈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
price = int(input())

change = 1000 - price
cnt_500 = change // 500
change = change % 500
cnt_100 = change // 100
change = change % 100
cnt_50 = change // 50
change = change % 50
cnt_10 = change // 10
change = change % 10
cnt_5 = change // 5
change = change % 5
cnt_1 = change // 1

total_cnt = cnt_500 + cnt_100 + cnt_50 + cnt_10 + cnt_5 + cnt_1
print(total_cnt)