Pay attention to the point ~
1 Switch statements
Note that the value of the expression in the parentheses after the:1> switch must be an integer or character type
The value following the 2>case can be a constant value, such as 1, 2, or a constant expression, such as A + T, but cannot be a variable or an expression with a variable, such as a * 2
After the 3> case is matched, the program code in the matching block is executed, and if no break is encountered, the contents of the next instance block will continue to be executed until the break statement or switch statement block ends as
4> can merge case statements with the same functionality
5> the default block can appear anywhere, or you can omit the
2 for Loop statement
Some small details to keep in mind:
1. The three expressions in parentheses after the For keyword must be separated by ";", and three expressions can be omitted, but ";" cannot be omitted.
A. Omit "loop variable initialization", which can be initialized by an assignment statement before the for statement, such as:
B. Omitting "cyclic conditions" may cause the cycle to continue, which is what we often call a "dead loop" phenomenon, such as:
Avoid the appearance of a "dead loop" during programming so that the above code can use break in the loop body to force a bounce out of the loop
C. Omit "Cyclic variable change", you can change the loop variable in the loop body, such as:
2. For loop variable initialization and cyclic variable changes, you can use "," to initialize or change the values of multiple loop variables, as
3, the loop condition part can use the combination of logical operators expression, to express complex judgment conditions, but must pay attention to the priority of the operation, such as:
3 Break Exit Loop
4 Continue Skip Cycle
The function of continue is to skip the remaining statements in the loop body to perform the next loop.
3. Process Control Statements