没有输出任何结果
输出结果为3
输出结果是3和4
输出结果是1、3和4
第1题:
已知如下代码: switch(m) { case 0: System.out.println("Condition0"); case 1: System.out.println("Condition 1"); case 2: System.out.println("Condition 2"); case 3: System.out.println("Condition 3"); break; default: System.out.println("Other cCndition"); } 当m为( )时,"Condition 2"会出现在输出结果中。
A.2
B.0、1
C.0、1、2
D.0、1、2、3
第2题:
以下代码的输出结果是什么? class Foo{ public static void main(String args[]){ int x=4,j=0; switch(x){ case 1:j++; case 2:j++; case 3:j++; case 4:j++; case 5:j++; break; default:j++; } System.out.println(j); } }()
A.1
B.2
C.3
D.编译错误
第3题:
程序:classTestApp{publicstaticvoidmain(String[]args){intX=5:switch(x){casel:case2:case3:System.out.println(一季度”);break;case4:case5:case6:System.out.println(二季度”);break;default:System.out.println(三季度以上”);break;}}}上述程序运行后的结果是哪项?()
A.一季度
B.二季度
C.三季度以上
D.无输出
第4题:
如下程序的输出结果是______。 #include<stdio.h> main() { int x,a=3,b=4; for(x=0;x<3;x++) { switch(x) { case 0:a--; case 1:b--; case 2:break; case 3:a--;b--; } } printf("a=%d,b=%d\n",a,B) ; }
A.a=2,b=2
B.a=3,b=3
C.a=1,b=2
D.a=3,b=2
第5题:
下列程序运行后的输出结果是 ______。
include<iostream.h>
void main()
{
int s=0,k
for(k=7;k>=0;k--)
{
switch(k)
{
case 1:
case 4:
case 7:s+ +;break:
case 2:
case 3:
case 6:break;
case 0:
case 5:s+=2;break;
}
第6题:
下列程序的输出结果是 #include<iostream.h> void main( ) {char*str="12123434"; int xl=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!='\0';i++) switch(str[i]) {case'1':x4++; case'2':x3++; case'3':x2++; case'4':x1++; } cout<<x1<<","<<x2<<","<<x3<<","<<x4; }
A.8,6,4,1
B.8,6,3,2
C.8,8,4,1
D.8,6,4,2
第7题:
以下程序的输出结果是main() { int x=l,a=2,b=3; switch(x) { case 0:b++; case 1:a++;break; case 2:a++;b++; } printf("a=%d,b=%d\n",a,b); }
a=3,b=3
第8题:
给出下列的程序片段,m为( )时将会输出default。 switch (m) case ():Systemt.out.println("case 0"); case 1: System.out.println("case 1");break; case 2:System.out.println("case2");break; default:System.out.println("default");
A.0
B.1
C.2 2
D.3
第9题:
下列程序的输出结果是 #include<iostream.h> void main() {char*str="12123434"; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!='\0';i++) switch(str[i]) {case'1':x4++; case'2':X3++; case'3':X2++; case'4':X1++; } cout<<X1<<","<
A.8,6,4,1
B.8,6,3,2
C.8,8,4,1
D.8,6,4,2
第10题:
下列程序的输出结果是_______。 main() { int i=3; switch(i) { case1: case 2:printf("%d",i) case 3: case 4:break; default : printf("OK") } }
A.0
B.3
C.OK
D.没有任何输出
第11题:
研究下面的Java代码: switch (x) { case 1: System.out.println(1); case 2: case 3: System.out.println(3); case 4: System.out.println(4); } 当x=2时,运行结果是()。
第12题:
没有输出任何结果
输出结果为3
输出结果是3和4
输出结果是1、3、4
第13题:
下列程序的输出结果是( )。 #include<iostream.h> void main() {char*str=”12123434”; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!=’\0’;i++) switch(str[i]) {case’1’:x4++; case’2’:x3++; case’3’:x2++; case’4’:xl++; ) cout<<xl<<“,”<<x2<<
A.8,6,4,1
B.8,6,3,2
C.8,8,4,l
D.8,6,4,2
第14题:
下列程序的输出结果是______。 main() { int i=3; switch(i) { case1: case2:printf("%d",i); case3: case4:break; default: printf ("OK"); } }
A.0
B.3
C.OK
D.没有任何输出
第15题:
如下程序的输出结果是______。 #include<stdio.h> main() { int x=1,a=3,b=4; switch(x) { case 0:a--; case 1:b--; case 2:a--;b--; } printf("a=%d,b=%d\n",a,b); }
A.a=2,b=2
B.a=3,b=3
C.a=1,b=2
D.a=3,b=2
第16题:
下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int i = 1; switch (i) { case 0: System.but.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); default: System.out.println ("default"); } } }
A.one
B.one, default
C.one, two, default
D.default
第17题:
给出下列的程序段,m为何值时将会输出default? ( ) switch(m) { case 0: System.out.println("case 0"); case 1:System.out.println("case 1");break; case 2:System.out.println("case 2");break; default:System.out.println("default"); }
A.0
B.1
C.2
D.3
第18题:
以下程序的输出结果是( )。 #include<stdio.h> main() {int a=8,b=6,m=1; switch(a%4) {case 0:m++; break; case 1:m++; switch(b%3) {default:m++; case 0:m++;break; } } printf("%d\n",m);}
A.1
B.2
C.3
D.4
第19题:
下列程序的输出结果是 #include<iostream.h> void main() { char*str="12123434"; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!=‘\0’;i++) switch(str[i]) { case'l':x4++; case'2':X3++; case'3':x2++; case'4':X1++; } cout << X1 << " ," << x2 << " ’" << x3 << " ," << X4; }
A.8,6,4,1
B.8,6,3,2
C.8,8,4,1
D.8,6,4,2
第20题:
给出下列的程序代码片段,m为哪个值时将会输出default? switch(m) { case 0:System.out.println("case0"); case 1:System.out.println("case 1");break; case 2:System.out.println("case 2");break; default:System.out.println("default"); }
A.0
B.1
C.2
D.3
第21题:
以下程序的输出结果是 #include<stdio.h> main() { int a=15/b=21,m=0; switch(a%3) { case0:m++;break; case 1:m ++; switch(b%2) { default:m++; case 0:m ++;break;}} printf("%d\n",m);}
A.1
B.2
C.3
D.4
第22题:
有如下代码段:
switch ( x ){
case 1:System.out.println("One");break;
case 2:
case 3:System.out.println("Two");break;
default:System.out.println("end");
}
变量x的取值下列哪些情形时,能使程序输出"Two" 。
A. 1
B. 2
C. 3
D. default
第23题:
swith(X){ case1: syso(1); case2: case3: syso(3); case4: syso(4); } 当X=2时,运行结果是()。