4.2.2 The switch statement that expresses the side-by-side condition selection: If ... If...... If......In the real world, there is a special kind of conditional choice:If it is sunny tomorrow, I will wear a T-shirt;If it is cloudy tomorrow, I will
4.2.2 The switch statement that expresses the side-by-side condition selection: If ... If...... If......In the real world, there is a special kind of conditional choice:If it is sunny tomorrow, I will wear a T-shirt;If it is cloudy tomorrow, I will
One way to "make something happen" is to evaluate an expression with a side effect. Injected assignments and function calls these expressions with side-effects can be used as separate statements, and this expression is also called an expression
In summary, the use of switch is to determine if the expression after the case matches the expression after switch, and once the case is matched, the subsequent program code is executed, regardless of whether the following case matches until the
Switch syntax The code is as follows:Copy code Switch (expression){Case constant expression 1: Statement 1;....Case constant expression 2: Statement 2;Default: statement;} Default is to execute it if there is no matching case. default is not
Switch-case retrun break, switch-caseretrun
{
If statements process two branches, the if-else-if structure must be used when processing multiple branches. However, if there are many branches, the more nested if statement layers, the program is not
The following example converts IF-ELSEIF-ELSE into a switch statement
Copy Code code as follows:
# Use If-elseif-else
If ($value-eq 1)
{
"Beijing"
}
Elseif ($value-eq 2)
{
"Shanghai"
}
Elseif ($value-eq 3)
{
If statements process two branches, the IF-else-If structure must be used when processing multiple branches. However, if there are many branches, the more nested if statement layers,ProgramIt is not only huge but also difficult to understand.
process switching based on kernel stack switching
Difficulty coefficient: ★★★★☆ Experiment objective to deeply understand the concept of process and process switching, synthesize application process, CPU management, PCB, LDT, kernel stack, kernel
First, If...else statement
If...else statement
Executes a piece of code when the condition is set, and executes another piece of code when the condition is not established
Grammar:
1. Simple condition
if (condition) {
......
}
else{
......
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.