Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C++ (https://www.askmehelpdesk.com/forumdisplay.php?f=439)
-   -   Random addition (https://www.askmehelpdesk.com/showthread.php?t=131202)

  • Sep 19, 2007, 02:55 AM
    meenagaurav
    random addition
    I want help to sum the diff. subset
    You are given n coins, each of different denomination ( for this take n different
    values as input from user).
    Let input is v1,v2,v3------,vn.

    You have to find how many different amounts you can pay by using these n coins.
  • Sep 21, 2007, 01:13 PM
    asterisk_man
    pseudo code (implementation is left as an exercise for the reader):

    for 0 < I <= n
    foreach combination genCombinations(vList I)
    print(sum(combination))

    there's probably an easier way to do it since generation of combinations this way will duplicate work but this is the easiest way to describe it.

  • All times are GMT -7. The time now is 05:53 PM.