title: Generating pairs of elements from array in C++
body: <p>If I have an array of elements for example:</p>
  
  <pre><code>int array[10] = {2,3,4,5,7}
  </code></pre>
  
  <p>What would be the fastest way to generate elements which have same difference?
  for example:</p>
  
  <p>if difference = 1<br>
  then elements are 2,3<br>
  if difference = 2<br>
  the pairs are (3,5) and (5,7)<br>
  and so on for all the differences</p>
  
  <p>I haven't taken any algorithm courses and I know only C++ language.</p>