当我得到一个数字时,我已经上了一堂课,要求我获得9的下一个最高间隔。这是我目前的代码。
int slot1 = (int) Math.floor(opposingPlayers/9.0);
int slot2 = slot1++;
int slot3 = slot2*9;
反对的球员正在回归。但是,当我运行代码时,
slot1 is equal to 1
slot2 is equal to 0
slot3 is equal to 0
然而,它应该是slot1 = 0 slot2 = 1 slot3 = 9
我只测试了对方球员返回一个,但它不应该改变任何东西。
答案 0 :(得分:1)
slot1++
将slot2
设置为slot1
(0),然后设置{icrements slot1
。你需要这个:
int slot1 = (int) Math.floor(opposingPlayers/9.0);
int slot2 = slot1 + 1;
int slot3 = slot2*9;
答案 1 :(得分:0)
您可以使用它来获得下一个最高9的间隔。
number + (9 - (number % 9))