程序填空题:写出与switch语句等价的else-if语句[4]
写出与以下switch语句等价的else-if语句。
```c++
switch (ch){
case '0' : case '1' : case '2' : case '3' : case '4' :
case '-':
minus++; break;
case '5' : case '6' : case '7' : case '8' : case '9' :
digit ++;break;
default:
other ++; break;
}
```
```c++
if@@[(ch == '-' || (ch >= '0' && ch <= '4') )](1) {
minus++;
}else if@@[(ch >= '5' && ch <= '9')](1) {
digit ++;
}else {
@@[other ++;](1)
}
```
答案:
第1空:(ch == '-' || (ch >= '0' && ch <= '4') )
第2空:(ch >= '5' && ch <= '9')
第3空:other ++;
```c++
switch (ch){
case '0' : case '1' : case '2' : case '3' : case '4' :
case '-':
minus++; break;
case '5' : case '6' : case '7' : case '8' : case '9' :
digit ++;break;
default:
other ++; break;
}
```
```c++
if@@[(ch == '-' || (ch >= '0' && ch <= '4') )](1) {
minus++;
}else if@@[(ch >= '5' && ch <= '9')](1) {
digit ++;
}else {
@@[other ++;](1)
}
```
答案:
第1空:(ch == '-' || (ch >= '0' && ch <= '4') )
第2空:(ch >= '5' && ch <= '9')
第3空:other ++;