我基本上是試圖解決通過遞歸硬幣找零的問題,這裏是我迄今爲止 - : #include<iostream>
#include<conio.h>
using namespace std;
int a[]={1,2,5,10,20,50,100,200},count=0;
//i is the array index we are working at
//a[] contains the
可能重複: Making change recursively: How do I modify my algorithm to print all combinations? 在硬幣圖案計數問題(給定一個值N和一組固定的硬幣的,我們要計算的組合的數量如果我們想打印組合而不是計算組合,那麼這種方法是什麼?我必須使用動態編程嗎?
我目前正在通過一本關於算法設計的書,並且遇到了一個問題,您必須通過動態編程實現貪婪算法來解決硬幣更換問題。 我試圖實現這一點,我只是無法弄清楚或理解我的書中給出的算法。該算法如下(我的(缺乏)的瞭解,評論): Change(p) {
C[0] = 0
for(i=1 to p) //cycling from 1 to the value of change we want, p