Saturday, June 18, 2005

Mutiplica dos matrices cuadradas de n orden

/*
* Created on 06/18/2005
*
* Mutiplica dos matrices cuadradas de n orden
*/
package estructura;

/**
* @author vns
*
*/
public class MultMatriz {

/**
*
*/
public MultMatriz() {
super();
}

public static void main(String[] args) {

}

//las matrices tienen que se cuadradas ej: 2x2, 3x3, etc
public static int[][] multiMatriz(int[][] a, int[][] b){
int[][]temp = new int[a.length][a.length];

for (int i = 0; i < temp.length; i++) {
for (int j = 0; j < temp.length; j++) {
int suma = 0;
for (int k = 0; k < temp.length; k++)
suma =+ a[i][k] * b[k][j];

temp[i][j] = suma;
}
}

return temp;
}
}

0 Comments:

Post a Comment

<< Home