1 //two two-dimensional array multiplication2#include <stdio.h>3#include <stdlib.h>4 #defineM 25 #defineN 36 //#define P 67 voidMain ()8 {9 inti,j,k;Ten //Two-dimensional arrays A and B are multiplied, and the product is placed in the array C One intA[m][n],b[n][m],c[m][m]; A //Enter the value of the element of the two-dimensional array a -printf"Please enter the elements of matrix A:"); - for(i=0; i<m;i++) the { - for(j=0; j<n;j++) - { -scanf"%d",&a[i][j]); + } - } +printf"\ n"); A //printing elements of a two-dimensional array a atprintf"matrix A is as follows: \ n"); - for(i=0; i<m;i++) - { - for(j=0; j<n;j++) - { -printf"%3d", A[i][j]); in } -printf"\ n"); to } +printf"\ n"); - //Enter the value of the element for the two-dimensional array b theprintf"Please enter the elements of matrix B:"); * for(i=0; i<n;i++) $ {Panax Notoginseng for(j=0; j<m;j++) - { thescanf"%d",&b[i][j]); + } A } theprintf"\ n"); + //printing elements of a two-dimensional array b -printf"Matrix B is as follows: \ n"); $ for(i=0; i<n;i++) $ { - for(j=0; j<m;j++) - { theprintf"%3d", B[i][j]); - }Wuyiprintf"\ n"); the } - //array Multiplication Wuprintf"\ n matrix a multiplied by matrix B results to: \ n"); - for(i=0; i<m;i++) About { $ for(j=0; j<m;j++) - { -C[I][J] =0; - for(k=0; k<n;k++) AC[I][J] = c[i][j]+a[i][k]*B[k][j]; + } the } -printf"\ n"); $ //values in array C are displayed in a branch the for(i=0; i<m;i++) the { the for(j=0; j<m;j++) the { -printf"%3d", C[i][j]); in } theprintf"\ n"); the } AboutSystem"Pause"); the}
Multiplication of two two-dimensional arrays (matrices)