题目
https://www.nowcoder.com/practice/bf358c3ac73e491585943bac94e309b0?tpId=190&&tqId=36251&rp=1&ru=/activity/oj&qru=/ta/job-code-high-rd/question-ranking
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
* @param a int整型二维数组 第一个矩阵
* @param b int整型二维数组 第二个矩阵
* @return int整型二维数组
*/
public static int[][] solve (int[][] a, int[][] b) {
if (a.length == 0 ){
return a;
}
int[][] result = new int[a.length][a[0].length];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
int sum = 0;
for (int k = 0; k < a.length; k++) {
sum += a[i][k] * b[k][j];
}
result[i][j] = sum;
}
}
return result;
// write code here
}
}
全部评论
(0) 回帖