Steering statement

xiaoxiao2021-03-06  41

Steering statement: 1.Break statement:

BREAK statement is used in While, Do ... While, for, and Switch statements. In Switch, Break is used to jump out of the Switch statement and continue to execute the Switch after Switch. In a circulating statement, Break is used to jump out of the nearest closed cycle.

For example: The following code continues to perform the statement at "A = 1;" after executing BREAK, not all cyclic for (;;) {for, {for (;;;) {// ... if (i == 1) Break; // ......

} A = 1; // Break jumps here // ...}

2.Continue statement: Continue statement is used in a loop statement, and the effect is ended in this cycle, that is, the statement that has not been executed in the cycle, followed by the next decision to perform a cycle. For example: The following code outputs the number of unable to output the number of 3 to 3 unless (int N = 100; n <= 200; n ) {IF (n% 3 == 0) CONTINUE;

Cout << n << endl; // ......

When N is divided, execute the CONTINUE statement, end the cycle, skip the COUT statement. Only N can't be divided by 3, only execute the COUT function

转载请注明原文地址:https://www.9cbs.com/read-56312.html

New Post(0)