如何在JAVA中建立距离 [英] How to make a distance in JAVA

查看:106
本文介绍了如何在JAVA中建立距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。我有二维数组,4x4作为乘法表,我必须在列之间创建一个空格,使得m和m之间的间隙等于给定列+1中最后一个数字的长度。 

< pre>
1234
2468
36912
481216





必看看

 1 2 3 4 
2 4 6 8
3 6 9 12
4 8 12 16





重点是每列之间的间距必须等于:+1列中最大数字的长度



我尝试了什么:



我尝试用循环做它没用完

解决方案

循环通过它,找到最大值。

然后你就可以工作了你需要多少空格(提示:任何值的日志 10 的整数部分是数字减去1),并使用它来格式化所有数字正确。

I have a question. I have two-dimensional arrays with 4x4 as a multiplication table and I have to make a space between columns such that the gap between m and m is equal to the length of the last number in the given column +1.

<pre>
1234
2468
36912
481216



It must look

1 2  3  4
2 4  6  8
3 6  9 12
4 8 12 16



The point is that the spacing between each column must be equal to: the length of the largest number in the +1 column

What I have tried:

I tried to do it with a loop and it did not work out

解决方案

Loop though it, and find the largest value.
You can then work out how many spaces you need (hint: the integer part of the log10 of any value is the number of digits minus 1), and use that to format all the numbers correctly.


这篇关于如何在JAVA中建立距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆