0
Program adding two matrix
matrix
2 Respuestas
+ 6
First you have to check they have the same dimensions (length for columns and rows), create a new matrix for the sum and
then use one for loop for the rows and another for the columns inside it, then you just set each sum value of "m1[i,j]+m2[i,j]"
+ 1
int m1[][]=new int[n][m];
int m2[][]=new int[n][m];
int a[][]=new int[n][m];
for(int I=0;I<n;I++)
{
for(int j=0;j<m;j++)
{
a[I][j]=m1[I][j]+m2[I][j];
}
}
//print matrix a[][]