java如何乘法二维数组?矩阵乘法
所以我有一个代码可以打印一个二维数组表。我遇到的问题是,我完全不知道如何乘法和求数组的乘积。感谢您的帮助。谢谢
public class MultiplyingArrays {
public static void main(String[] args) {
int firstarray[][] = {{1, 2, -2, 0}, {-3, 4, 7, 2}, {6, 0, 3, 1}};
int secondarray[][] = {{-1, 3}, {0, 9}, {1, -11}, {4, -5}};
System.out.println("This is the first array");
display(firstarray);
System.out.println("This is the second array");
display(secondarray);
}
public static void display(int x[][]) {
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.print(x[row][column] + "\t");
}
System.out.println();
}
}
}
预期的结果将是:
-3 43
18 60
1 -20
# 1 楼答案
# 2 楼答案
请使用适当的naming convention
# 3 楼答案
对于喜欢这种方法的人:
输出结果如下所示