main( )[br][/br]{ int x=1,a=0,b=0;[br][/br]switch(x)[br][/br]{ case 0:b++;[br][/br] case 1:a++;[br][/br] case 2:a++;b++; }[br][/br]printf("a=%d,b=%d",a,b); }输出结果是________
举一反三
- The switch statement with different functions from the statement if (a == 1) a = b; else a ++; is ( ). A: switch(a) { case 1:a=b;break; <br/>default : a++; <br/>} B: switch(a==1) { case 0:a=b;break;<br/>case 1: a++;<br/>} C: switch(a) { default:a++;break; <br/>case 1:a=b; <br/>} D: switch(a) { default:a++;break; <br/>case 1:a=b; <br/>}
- 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
- 若a和b均是整型变量,正确的switch语句是( )。 A: switch(pow(a,2)+pow(b,2)); (注:调用求幂的数学函数) <br/>{ <br/>case 1 : case 3 : y=a+b;break; <br/>case 0 : case 5 : y=a-b; <br/>} B: switch(a*a+b*b) <br/>{ <br/>case 3 : <br/>case 1 : y=a+b; break; <br/>case 0 : y=b-a; break; <br/>} C: switch a <br/>{ <br/>default :x=a+b; <br/>case 10 : y=a-b; break; <br/>case 11 : x=a*d; break; <br/>} D: switch(a+b) <br/>{ <br/>case10 : x=a+b; break; <br/>case11 : y=a-b; break; <br/>}
- 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",a,b); } 该程序的输出结果是( )
- 若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/>}