title: Comparison of all array elements - C algorithm
body: <p>I have a matrix <em>m</em> * <em>n</em> and, for each row, I need to compare all elements among them.
  For each couple I find, I'll call a function that is going to perform some calculations.</p>
  
  <p>Example:</p>
  
  <pre><code>my_array -&gt; {1, 2, 3, 4, 5, ...}
  
  I take 1 and I have: (1,2)(1,3)(1,4)(1,5)
  I take 2 and I have: (2,1)(2,3)(2,4)(2,5)
  and so on
  </code></pre>
  
  <p>Using C I wrote this:</p>
  
  <pre><code>for (i=0; i&lt;array_length; i++) {
      for (k=0; k&lt;array_length; k++) {
          if (i==k) continue;
  
             //Do something
          }
      }
  }
  </code></pre>
  
  <p>I was wondering if I can use an algorithm with lower complexity.</p>