Why? for(i=1;i<=10;i++) Only cycle 5 Time
CSDN Q & A 2022-02-13 06:29:17 阅读数:305
Why? for(i=1;i<=10;i++) Only cycle 5 Time
for(i=1;i<=10;i++) Only cycle 5 Not usually , Unless it's yours for Restrictions are added to the loop body
for example
1.if(i==5) break; perhaps while loop , The main reason is that these statements contain return perhaps break perhaps continue key word , The first two of these three are the direct end of the loop , The latter one is to jump out of this cycle , So let's do the next loop
2.for There are changes in the loop i Conditions , such as for(i=1;i<=10;i++){.....i=i+2} such i The value of , Of course, it won't add... At one time 1 了
Just this code , Should be for There is also code in the loop, which affects the number of cycles
The mistakes that newcomers often make , Two layers of circulation
for (i=1;i<10;i++){
i++
}
perhaps
for (i=1;i<10;i++){
for(j=1;i<6;i++){
}
}
I think your code should have i++ Relevant code , perhaps break.
Look at the code in your loop .
copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130629153987.html