title: Cartesian Product in c++
body: <p>I have been searching for weeks on how to come up with piece of code which I could applied the cartesian product. Let's say I have two arrays : </p>
  
  <pre><code>int M[2]= {1,2};
  int J[3] = {0,1,2};
  </code></pre>
  
  <p>So the code will takes those two arrays in apply the rule M X J
  therefore we will have the pairs (1,0)(1,1)(1,2)(2,0)(2,1)(2,2) and I want the new result to be saved into a new array where each index in the array contains a pair , for example c[0] = (1,0).
  Help please :(</p>