title: Finding permutation and combination in C++
body: <p>I want to find a series of numbers of dynamic length in C++. Suppose I have 2 groups of numbers: <code>arr1[3] = {1, 3, 8}</code> and <code>arr2[4] = {2, 9}</code>, then the expected output is:</p>
  
  <pre><code>'1, 2',
  '1, 9',
  '3, 2',
  '3, 9',
  '8, 2',
  '8, 9'.
  </code></pre>
  
  <p>However, if there are 3 groups now : <code>arr1[3] = {1, 3, 8}</code>, <code>arr2[2] = {2, 9}</code> and <code>arr3[5] = {1, 3, 9}</code> then the output should be:</p>
  
  <pre><code>'1, 2, 1',
  '1, 2, 3',
  '1, 2, 9',
  '1, 9, 1',
  '1, 9, 3',
  '1, 9, 9',
  '3, 2, 1',
  '3, 2, 3',
  '3, 2, 9',
  '3, 9, 1',
  '3, 9, 3',
  '3, 9, 9',
  </code></pre>
  
  <p>and so on...</p>
  
  <p>So there will 3 x 2 x 3 = 18 outcomes. I got the outcome for 2 groups and 3 groups using respective numbers of for loops.</p>
  
  <p>See this code for 2 groups:</p>
  
  <pre><code>for(int i=1;i&lt;=5;i++) { 
     for (int j=1;j&lt;=5;j++) { 
         cout &lt;&lt; i &lt;&lt; "," &lt;&lt; j &lt;&lt; "," &lt;&lt; endl; 
     } 
  }
  </code></pre>
  
  <p>But then I have to use different codes for different value of group number and have to use switch statement or if-else statement to choose that portion of code.</p>
  
  <p>This will be a great help. Thanks in advance!</p>