/////// Matrix multiplication /////// #include int rtc(int *row, int *col, int s, int t) { int sum=0; while ( s-- > 0 ) { sum += *row++ * *col; col += t; } return(sum); } void matmul(int *a, int *b, int* c, int r, int s, int t) { int i,j; for (i=0 ; i < r ; i++) { a += i*s; for (j=0 ; j < t ; j++) *c++ = rtc(a,b+j,s,t); } } int main() { int a[2][3]= { {1,-2,5}, {1,2,3}}; int b[3][2]= { {9,7},{-2,3},{-1,4}}; int c[2][2]; matmul(*a,*b,*c,2,3,2); cout << "( " << c[0][0] << " " << c[0][1] << ")\n( " << c[1][0] << " " << c[1][1] << ")\n"; return(0); }