c ++ for loop judgment condition

Problems : Let m and n are int type, then the for loop, ()

The include # <stdio.h>
int main ()
{
int m, n-;
for (m = 0, n-= -1; n-= 0; m ++, n-++)        // for (variable initial value; loop judgment condition ; variable calculated) 0 to false, zero is to true
{
n-++;
the printf ( "% D", n-);
}
return 0;
}

 
loop never be executed; perform a loop; is infinite loop; finite cycles; loop end determination condition is not valid; Run Error

Experimental : when n = 0, the compiler does not display any number; when n = 1, by the compiler, the results show unlimited .... 222; and when n = -1, compiler, operating results unlimited 0000

Analysis : Analyzing the condition n = 0, whenever, n-have the value 0, and the return value of the assignment expression i.e. the assignment itself, i.e., 0, is thus considered to be false, and therefore, for loop statement never It is executed.

 

Guess you like

Origin www.cnblogs.com/g6z3z/p/11291474.html