零錢換算問題
Chapter 9 Recursion
請用遞迴的方式,寫一個程式計算一筆錢可以有幾種組合,並將所有可能的組合列出來。
面額依照新台幣有1000,500,100,50,10,5,1六種。
說明:以13元為例。可以有四種組合。
(1)1個10元,3個1元。
(2)2個5元,3個1元。
(3)1個5元,8個1元。
(4)13個1元。
How much money? 13
(0,0,0,0,1,0,3);(0,0,0,0,0,2,3);(0,0,0,0,0,1,8);(0,0,0,0,0,0,13)
There are 4 possible combinations.
--
※ 發信站: 批踢踢實業坊(ptt.twbbs.org)
◆ From: NeedGem.m7.ntu.edu.tw