C++ Multiplying 2 ND Matrices
<p>Tricky question, how to multiply 2 ND metrices? of course columnsA == rowsB...
Here's what i've got:</p>

<pre><code>void multiply(int *A, int *B, int r1, int c1, int r2, int c2) {
     int sum = 0;
     for (int i=0;i&lt;(c1*r2);i++) {
         for (int j=0;j&lt;c1;j++) {
             sum += A[(i-i%c1)+j] * B[(i%c1)+j*c1];
         }
         cout &lt;&lt; sum &lt;&lt; " ";
         sum = 0;
    }
}
</code></pre>

<p>Calling it:</p>

<pre><code>multiply(&amp;A[0][0],&amp;B[0][0],rowsA,columnsA,rowsB,columnsB);
</code></pre>

<p>Works only for rectangular matrices, obviously. Any suggestion? :)</p>
