General - the execution order of the for statement

example:

for(int i = 0; i < 10; i++)
{
    
    
	//循环内代码
}

(Represent the above for statement as: for(A; B; C))

The execution sequence is:
1. Execute A
2. Judgment B, if it is true, enter the loop, if it is false, skip (jump out) the loop
3. After completing a loop, execute C
4. Repeat steps 2 and 3 until it is judged that B is After false, break out of the loop

The execution result of this example is: jump out of the loop when i==10

Inside the loop, you can also use break to directly jump out of the loop
, or use continue to go directly to the next round of loop

Guess you like

Origin blog.csdn.net/Dugege007/article/details/91374790