May 2021 1 88 Report
coin change problem code doesn't work?

here is the code:int coin-change(int value,int index)

{if(value==0)

return 1;

if(index<0)

return 0;

if(index<0&&value>=1)

return 0;

else

return coin-change(value-coins[index],index)+coin-change(value,index+1);

}

int coins={1,5,10,20,50};int t=10;

i can't run it on c++ (no syntax error) but when i try running it starting from coin-change(t,4) it refuses and gives me logical error (the code itself comes from algorithmist site

Update:

here is the link

http://www.algorithmist.com/index.php/Coin_Change

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 QUIZLS.COM - All rights reserved.