-3

我需要一点帮助。我基本上是想计算世界上两个坐标之间的块数,但是正如你所见,我的数学不太好,所以如果你有解决方案,请写信给我。这很重要,所以请写下来,我将不胜感激!

int x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0;
x2 = x // pos x in the coord
y2 = y // pos y in the coord
z2 = z // pos z in the coord
x1 = x;
y1 = y;
z1 = z;
int a = Math.abs(Math.abs(x1)-(Math.abs(x2)));
int b = Math.abs(Math.abs(y1)-(Math.abs(y2)));
int c = Math.abs(Math.abs(z1)-(Math.abs(z2)));
if(x2 != 0)
int volume = a*b*c;
4

1 回答 1

1

的距离不正确a,b,c

// int a = Math.abs(Math.abs(x1)-(Math.abs(x2)));
int a = Math.abs(x1 - x2);

当然,正如@Ted Hopp 所指出的,代码需要一些除 0 之外的有趣值来做很多事情。

int x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0;
于 2014-09-28T00:38:00.083 回答