title: 'for' loops for making groups of combination
body: <p>I have an array in c++ with unknown entries (minimum 6) i need a for loop (probably includes a few for loop) which makes 3 groups of 2. I don't care about order of groups or in the group. And tricky part is that double counting is not allowed. I tried something like this but it is obviously triple counts...</p>
  
  <pre><code>for(int i = 0; i &lt; nArray - 1; i++)
  {
    for(int j = i+1; j &lt; nArray; j++)
    {
      for(int k = 0; k &lt; nArray - 1; k++)
      {
        for(int l = k+1; l &lt; nArray; l++)
        {
          for(int m = 0; m &lt; nArray - 1; m++)
          {
            for(int n = m+1; n &lt; nArray; n++)
            {
              if(k!=i &amp;&amp; k!=j &amp;&amp; l!=i &amp;&amp; l!=j &amp;&amp; m!=i &amp;&amp; m!=j &amp;&amp; n!=i &amp;&amp; n!=j &amp;&amp; m!=k &amp;&amp; m!=l &amp;&amp; n!=k &amp;&amp; n!=l)
              {
                std::cout &lt;&lt; array[i] &lt;&lt; "-" &lt;&lt; array[j] &lt;&lt; std::endl  &lt;&lt; array[k] &lt;&lt; "-" &lt;&lt; array[l] &lt;&lt; std::endl &lt;&lt; array[m] &lt;&lt; "-" &lt;&lt; array[n] &lt;&lt; std::endl &lt;&lt; std::endl;
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Edit: for example let our array is {1,2,3,4,5,6} which has 6 entries. Output should look like:</p>
  
  <pre><code> 12-34-56
   12-35-46
   12-36-45
   13-24-56
   13-25-46
   13-26-45
   14-23-56
   14-25-36
   14-26-35
   15-23-46
   15-24-36
   15-26-34
   16-23-45
   16-24-35
   16-25-34
  </code></pre>
  
  <p>But there should not be 12-43-56 or 34-12-56 since there is 12-34-56.</p>
  
  <p>And for the array {1,2,3,4,5,6,7}</p>
  
  <pre><code>12-34-56
  12-34-57
  12-34-67
  12-35-46
  12-35-47
  12-35-67
  ...
  </code></pre>
  
  <p>and so on.</p>