若a、b、cl、c2、x、y均是整型变量,以下正确的switch语句是()。
A: switch( a+b );{ case 1:y=a+b; break;case 0:y=a-b; break; }<br><br>
B: switch( a*a+b*b );{ case 3;case 1:y=a+b; break;case 3:y=b-a; break; }<br><br>
C: switch a{ case c1 :y=a-b; break;case c2: x=a*d; break;default: x=a+b; }<br><br>
D: switch( a-b );default: y=a*b; break;case 3: case 4:x=a+d; break;case 10: case 11:y=a-d; break; }<br><br>
A: switch( a+b );{ case 1:y=a+b; break;case 0:y=a-b; break; }<br><br>
B: switch( a*a+b*b );{ case 3;case 1:y=a+b; break;case 3:y=b-a; break; }<br><br>
C: switch a{ case c1 :y=a-b; break;case c2: x=a*d; break;default: x=a+b; }<br><br>
D: switch( a-b );default: y=a*b; break;case 3: case 4:x=a+d; break;case 10: case 11:y=a-d; break; }<br><br>
举一反三
- 若a和b均是整型变量,以下正确的switch语句是【】 A: switch (a/b) <br/>{ case 1: case 3.2: y=a+b; break ;<br/>case 0: case 5: y=a-b;<br/>} B: switch (a*a+b*b); <br/>{case 3:<br/>case 1: y=a+b; break ;<br/>case 0: y=b-a; break; } C: switch a <br/>{default : x=a+b;<br/>case 10 : y=a-b;break;<br/>case 11 : y=a*d; break;} D: switch(a+b)<br/>{case 10: x=a+b; break;<br/>case 11: y=a-b; break;<br/>}
- 若a、b、c1、c2、x、y均是整型变量,正确的switch语句是______。①switch(a+b);{ case 1:y=a+b;break;case 0:y=a-b;break;}②switch(a*a+b*b){ case 3:case 1:y=a+b;break;case 3:y=b-a;break;}③switch { case c1:y=a-b;break;case c2:x=a*b;break;default:x=a+b;}④switch (a-b){ default:y=a*b;break;case 3:case 4:x=a+b;break;case 10:case 11:y=a-b;break;} A: ① B: ② C: ③ D: ④
- 若a、b、c1、c2、x、y均是整型变量,以下正确的switch语句是 A: swich(a+b);{ case 1 : y=a+b; break;case 0 : y=a-b; break; } B: switch(a*a+b*b){ case 3 :case 1 : y=a+b; break;case 3 : y=b-a, break; } C: switch a{ case c1 : y=a-b; break;case c2 : x=a*d; break;default : x=a+b; } D: switch(a-b){ default : y=a*b; break;case 3 : case 4 : x=a+b;break;case 10 : case 11: y=a-b: break; }
- 以下switch语句结构哪一个是正确的?( ) A: int a=1,b=0,c1,c2,x,y;switch (a*a+b*b) { case 3: case 1: y=a+b; break; case 3: y=b-a; break;} B: int a=1,b=0,c1,c2,x,y;switch a ( ) { case c1: y=a-b; break; case c2: x=a*b; break; default:x=a+b;} C: int a=1,b=0,c1,c2,x,y;switch (a*a+b*b) { default:y=a*b;break; case 3: x=a+b; break; case 10: case 11:y=a-b; break;} D: int a=1,b=0,c1,c2,x,y;switch (a+b); { case 1: y=a+b; break; case 0: y=a-b; break; }
- 若a和b均是正整型变量,正确的switch语句是( ) A: switch(pow(a,2)+pow(b,2)) {case 1:case:y=a+b;break; case 0:case 5:y=a-b;} B: switch(a*a+b*b);{case 3:case 1:y=a+b;break;case 0:y=b-a; break; } C: switch a{default:x=a+b; case 10:y=a-b;break;case 11:y=a-b;break;} D: switch(a+b){case 10:x=a+b;break;case 11:y=a-b;break;}