VPeric, I'm having trouble with your code even though it makes sense in my head. The coding of it seems to give me a loop that goes on infinitely.
Apparently C always passes arrays as a reference
All the workarounds seem quite involved like creating a structure that hold the array, which can the be passed as a copy by value.
That's probably why my code gets going forever.
Anyone know of an easier way to make this work…
This project is giving me a headache
I understand the solutions in my head, but I can't seem to make them work
EDIT:
I made a struct. And I passed it on to the function. For some reason my :
solutions+=function(coinsstruct,(Value-coinsstruct.a));
stops subtracting from value after going through one loop …
It just keeps the Value at a constant value and goes through the loop forever…
Should I post my code ?
EDIT2:
Apparently I'm thinking too hard. I'm not supposed to add new things to the main code and basically just use the function call
function(int Value, int coins[], int n)
And I'm supposed to use dynamic programming, basically what you guys said of solving the subproblems first.
EDIT3: The infinite loop is because I put the coins = 0 ….
So then value - 0 = always value
and it keeps going on forever
//SNIP SNIP
I tried making a copy of the coins and copying the elements in.
Apparently C always passes arrays as a reference
All the workarounds seem quite involved like creating a structure that hold the array, which can the be passed as a copy by value.
That's probably why my code gets going forever.
Anyone know of an easier way to make this work…
This project is giving me a headache
I understand the solutions in my head, but I can't seem to make them work
EDIT:
I made a struct. And I passed it on to the function. For some reason my :
solutions+=function(coinsstruct,(Value-coinsstruct.a));
stops subtracting from value after going through one loop …
It just keeps the Value at a constant value and goes through the loop forever…
Should I post my code ?
EDIT2:
Apparently I'm thinking too hard. I'm not supposed to add new things to the main code and basically just use the function call
function(int Value, int coins[], int n)
And I'm supposed to use dynamic programming, basically what you guys said of solving the subproblems first.
EDIT3: The infinite loop is because I put the coins = 0 ….
So then value - 0 = always value
and it keeps going on forever
//SNIP SNIP
I tried making a copy of the coins and copying the elements in.
Last edited: