title: SubsetSum Printing the list
body: <p>The problem is to print all subsets that sum up to a value. I wrote code to check if there is a possible subset. Can some one gimme an idea to print the numbers that form the sum. Below is my code. Assume the array contains only +ve nos for simplicity.</p>
  
  <pre><code>void subsetsum(int A[], int target) {
  
  int N = sizeof(A)/sizeof(int), sum = 0;
  
  for(int i = 0; i &lt; N; i++) sum += A[i];
  
  vector&lt;bool&gt; V(sum + 1, 0);
  V[0] = 1;
  for(int i = 0; i &lt; N; i++) 
     for(int j = sum; j &gt;= 0; j--) {
        if(j + A[i] &lt;= sum &amp;&amp; V[j]) V[A[i] + j] = 1;
     }
    if(V[target]) cout &lt;&lt; "Sumbset sum exists" &lt;&lt; endl;
    else cout &lt;&lt; "Sumbset sum doesnt exist" &lt;&lt; endl;
  }
  </code></pre>