若有以下定义: float x;int a,b;则正确的switch 语句是
A: switch(x){case 1:a++;case 2:b++;}
B: switch(x){case 1,2:a++;case 2:b++;}
C: switch(a+b){case 1,2:a++;case 2:b++;}
D: switch(a+b){case 1:a++;case 2:b++;}
A: switch(x){case 1:a++;case 2:b++;}
B: switch(x){case 1,2:a++;case 2:b++;}
C: switch(a+b){case 1,2:a++;case 2:b++;}
D: switch(a+b){case 1:a++;case 2:b++;}
举一反三
- 若有定义语句int a, b;double x;则下列选项中正确的是( ). A: switch(x%2) { case 0: a++; break; case 1: b++; break; default : a++; b++; } B: switch((int)x/2.0) { case 1: b++; break; case 0: a++; break; default : a++; b++; } C: switch((int)x%2) { case 0: a++; break; case 1: b++; break; default : a++; b++; } D: switch((int)(x)%2) { case 0.0: a++; break; case 1.0: b++; break; default : a++; b++; }
- main() {int x=1,a=0,b=0; switch (x) { case 0: b++; case 1: a++; case 2: a++;b++;} printf("a=%d,b=%d
- 中国大学MOOC: 下面程序的输出是( ) int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0: a++;break; case 1: b++;break; } case 2: a++;b++;break; }
- 04410012:写出下面程序输出结果( )。 int main( ) { int x=1, y=0, a=0, b=0; switch(x) {case 1: switch(y) { case 0: a++; case 1: b++; } case 2: a++; b++; } printf("a=%d, b=%d ", a, b) ; }
- 以下程序段的输出结果是( ) int x=1,a=0,b=0; switch(x) {case 0:b++; case 1:a++; case 2:a++;b++; } printf("a=%d,b=%d",a,b);