0
I have to multiply three matrices with the validation that you can actually do, in one function. I’m trying to do matrix 1 and 2 first and get the result to do the 3. But it’s going wrong and also I can’t call the result on main.
public static int[][] mult(int linha, int coluna, int linha2, int coluna2, int linha3, int coluna3, int[][] matriz, int[][] matriz2, int[][] matriz3) {
if(matriz[0].length == matriz2.length){
int[][] matrizR = new int[linha][coluna2];
for(int i = 0; i < linha; i++){
for(int j = 0; j < coluna2; j++)
for(int k = 0; k < linha2; k++)
matrizR[i][j] = matriz[i][k] * matriz2[k][j];
}
return matrizR;
}
if(matrizR[0].length == matriz3.length){
int[][] resultado = new int[linha][coluna3];
for(int i = 0; i < linha; i++){
for(int j = 0; j < coluna3; j++)
for(int k = 0; k < linha2; k++)
resultado[i][j] = matrizR[i][k] * matriz3[k][j];
}
return resultado;
}
}