Turn while loop into math equation?

后端 未结 4 1022
无人及你
无人及你 2021-02-05 10:56

I have two simple while loops in my program that I feel ought to be math equations, but I\'m struggling to convert them:

float a = someValue;
int b = someOtherVa         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 11:43

    c = (int)((a - (b / 2)) / b + 1);
    a -= c * b;
    

    Test case at http://pastebin.com/m1034e639

提交回复
热议问题