grammar structure:
if(布尔表达式1) {
语句块1;
} else if(布尔表达式2) {
语句块2;
}……
else if(布尔表达式n){
语句块n;
} else {
语句块n+1;
}
When a Boolean expression is true, a block statement is executed; otherwise, determining a Boolean expression 2, when the Boolean expression 2 is true, execute statement blocks 2; otherwise, continue to determine the Boolean expression 3 ······ ; if 1 ~ n boolean expressions are determined as false, the statements block n + 1, i.e. the else part. Flow chart shown in Figure 3-7.
FIGS. 3-7 if-else if-else flowchart multiple selection structure
[Example 3-5] if-else if-else multiple selection structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Figure 3-8 Example 3-5 FIG 1 operating results