以矩阵格式java打印2d数组
如何以精细格式打印二维数组
我想打印如下所示的矩阵,数字最多4个空格,小数最多2个空格 例如xxxx。xx
double A[][]= {
{ 3.152 ,96.1 , 77.12},
{ 608.12358 , -5.15412456453 , -36.1},
{ -753..555555, 6000.156564 , -155.541654}
};
//I need this output
3.15 | 96.10 | 77.12
608.12 | -5.15 | -36.10
-753.55 | 6000.15 | -155.54
# 1 楼答案
这里有一种方法:
结果: