【发布时间】:2014-02-28 03:01:04
【问题描述】:
所以我有一个代码可以打印一个二维数组表。我遇到的问题是我完全不知道如何相乘并找到数组的乘积。任何帮助表示赞赏。谢谢
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
【问题讨论】:
-
你的意思是矩阵乘法吗? en.wikipedia.org/wiki/Matrix_multiplication
-
是的,抱歉应该说清楚