Multiple conditions in for statement

前端 未结 4 1538
有刺的猬
有刺的猬 2021-01-28 02:20

I have this code in a function, but when it runs it does a long pause and then it says:

$floating point exception

I am assuming this is due to

4条回答
  •  离开以前
    2021-01-28 03:08

    Remember that the condition is for the loop to continue, not for it to end.

    It's difficult to look at your code and see intuitively what you're trying to do. Although you could fix this by flipping some logic around (you meant (i < number && j != 1)), it's best to stop and use break inside the loop instead. The logic will be far clearer, and then you won't make errors like this.

提交回复
热议问题