【发布时间】:2015-03-15 15:02:43
【问题描述】:
如何格式化二维数组,以便打印出一种矩阵“样式”。
例如,在这个代码数组的 sn-p 中,得到两个二维 int 数组的乘积。
说一个像这样的 2x2 矩阵
59 96
78 51
在打印出来的命令提示符中,它最终会像这样显示
59 96 78 51
如何让它以行列的矩阵格式显示。
2X2 只是这个程序中的一个例子,二维数组必须大于或等于 50。
else
{
int[][] array;
//this will hold the multiplied thing
array=multiply(matrix,matrix2);
System.out.println("this is the result of the multiplication");
//print out the array
for(int i=0; i<row; i++)
{
for( int j=0; j< col2; j++)
{
System.out.print(array[i][j] + " \t");
}
}
【问题讨论】: