1 //Code by ZZLPP2#include <stdio.h>3#include <stdlib.h>4 5 voidMatrix_multiply (int(MS,int(MP,int*R,6 int ConstXint ConstYint Constz);7 8 9 intMainvoid )Ten { One //Initialize the original matrix A intm1[3][1]={1,2,3}, -m2[1][3]={3,2,1}, -r[3][3]={{},{},{}}; the - intI, - J; - //calling Functions +Matrix_multiply (*m1,*m2,*r,3,1,3); - //print the resulting matrix + for(i=0;i<3; i++ ) A { at for(j=0;j<3; j + + ) - { -printf"%d", R[i][j]); - } -printf"\ n"); - } inSystem"Pause" ); - return 0; to } + - voidMatrix_multiply (int(MS,int*M2,int*R, the int ConstXint ConstYint Constz) * { $ intRow//corresponding to xPanax NotoginsengColumn//corresponds to Y -Direction//corresponds to Z the int*m1_cpy, +*m2_cpy; A for(row=0; row<x;row++ ) the { + for(direction=0;d irection<z;direction++ ) - { $m1_cpy=m1+row*y; $m2_cpy=m2+direction; - for(column=0; column<y;column++ ) - { the*r+= (*m1_cpy) * (*m2_cpy); -m1_cpy+=1;Wuyim2_cpy+=direction; the } -r++; Wu } - } About}
This code is mainly familiar with multidimensional arrays, in the function of the time to pay attention to the method, while operating multidimensional arrays in the function also requires a method, if the use of the following table reference is not feasible, you must set a special variable as the following table (Row,column,direction). Of course, my understanding is one-sided, many Haihan.
C and Pointer notes--multiplication of arrays