Home > Back-end >  The while loop problem
The while loop problem

Time:06-07

Anyone who can tell me why the output is the result of the two?

CodePudding user response:

While (x - 2) here is equivalent to the while (x> 2)
And then obviously

CodePudding user response:

Because when x=2, while the return value is false not for circulation

CodePudding user response:

While whether x - 2 to 0, if 0 exit the loop, or other values are execution loop body ~

CodePudding user response:

reference 1st floor Zhu Mingde response:
while here (x - 2) is equivalent to the while (x> 2)
And then obviously it
accurately should be equivalent to the while (x!=2)

CodePudding user response:

reference 3 building self-confidence boy reply:
while whether x - 2 to 0, if 0 exit the loop, or other values are performed loop body ~

I see, thank you (* ^ ^ *) omega

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related