代碼如下:
public interface IMatrixMultiple {
public int[][] mmltiple(int[][]a ,int [][]b);
}
?public class MatrixMultiple implements IMatrixMultiple {
@Override
public int[][] mmltiple(int[][] a, int[][] b) {
int [][] result = new int[a.length][b[0].length];
for (int i = 0; i<a.length; i++) {
for (int j = 0; j<b[0].length; j++) {
for (int k = 0; k<a[0].length; k++) {
result[i][j]= result[i][j]+a[i][k]*b[k][j];
}
}
}
return result;
}
}