- The following C program is to perform matrix mulitplication and print out the result
- #include<stdio.h>
- #define ROW1 2
- #define ROW2 4
- #define COL 3
- void multiply(int [][COL],int[][ROW2],int[][ROW2]);
- int void(void)
- {
- int array[ROW1][COL]={{1,2,3},
- {4,5,6}};
- int array2[COL][ROW2]={{3,6,1,2},
- {5,4,3,2},
- {1,2,5,6}};
- int result[ROW1][ROW2];
-
- multiply(array1,array2,result);//call the function multipy
- size_t i,j;
- for(i=0;i<ROW1;i++)
- {
- for(int j=0;j<ROW2;j++)
- {
- printf("%d ",result[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
複製代碼 Please finish the definition/code of the function multiply(), which recevies two two-dimensional arrays(array1 and array2),perform the martrix multiplication, and then store the outcome in the third two-dimensional array(result). |