2019-07-11 16:50:07 Python

Python

Copy Copied! Full
# お金を紙幣と小銭に分けるプログラム input_money = input('金額を入力してください:') balance = int(input_money) man = 0 gosen = 0 sen = 0 gohyaku = 0 hyaku = 0 goju = 0 ju = 0 go = 0 iti = 0 while balance >= 10000: balance -= 10000 man += 1 while balance >= 5000: balance -= 5000 gosen += 1 while balance >= 1000: balance -= 1000 sen += 1 while balance >= 500: balance -= 500 gohyaku += 1 while balance >= 100: balance -= 100 hyaku += 1 while balance >= 50: balance -= 50 goju += 1 while balance >= 10: balance -= 10 ju += 1 while balance >= 5: balance -= 5 go += 1 iti = balance print('1万円札:' + str(man) + '枚') print('5千円札:' + str(gosen) + '枚') print('千円札:' + str(sen) + '枚') print('500円玉:' + str(gohyaku) + '枚') print('100円玉:' + str(hyaku) + '枚') print('50円玉:' + str(goju) + '枚') print('10円玉:' + str(ju) + '枚') print('5円玉:' + str(go) + '枚') print('1円玉:' + str(iti) + '枚')
RECOMMEND