The C Programming Language書中3.4 Switch 開頭這麼寫到:
3.4 Switch
The switch statement is a multi-way decision that tests whether an expression matches one of a number of constant integer values, and branches accordingly.
switch (expression) {
case const-expr: statements
case const-expr: statements
default: statements
}
_Each case is labeled by one or more integer-valued constants or constant expressions. _If a case matches the expression value, execution starts at that case. All case expressions must be different. The case labeled default is executed if none of the other cases are satisfied. A default is optional; if it isn't there and if none of the cases match, no action at all takes place. Cases and the default clause can occur in any order.
我不明白,就粗斜體部分,每一個標簽應該只是一個整型常量值或者整型表達式。書上為什麼寫 one or more,意思是每個case標簽也可以是多個整型常量值或整型表達式???
你英文不好,注意是labeled,也就是每個常量用標簽標記的,所謂標簽,就是一個帶有冒號的標注。