EasyMath.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:easyMath 作者:
public static int[][] multiply2DMatrix(int[][] firstMatrix,
        int[][] secondMatrix) {
    int[][] result = new int[firstMatrix.length][secondMatrix[0].length];
    if (firstMatrix[0].length == secondMatrix.length) {
        for (int i = 0; i < firstMatrix.length; i++) {
            for (int j = 0; j < secondMatrix[0].length; j++) {
                for (int k = 0; k < firstMatrix[0].length; k++) {
                    result[i][j] += firstMatrix[i][k] * secondMatrix[k][j];
                }
            }
        }
    } else {
        throw new RuntimeErrorException(null,
                "Column number of first matrix" + "("
                        + firstMatrix[0].length
                        + ")  is not equal to row number" + "("
                        + secondMatrix.length + ") of second matrix");
    }
    return result;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号