执行语句序列 intn: cin>>n: switch(n) { casel: case2:cout<<'1': case 3: case4:cout<<'2': break: delhult:cout<<'3': } 时,若键盘输入1,则屏幕显示
A.1
B.2
C.3
D.12
第1题:
执行语句序列: int n; cin>>n; switch(n) { case 1: case 2:cout<<'1'; case 3: case 4:cout<<'2';break; default:cout<<'3'; }时,若从键盘输入1,则屏幕显示______ 。
A.1
B.2
C.3
D.12
第2题:
执行如下语句序列,不可能出现的情况是: int n; cin>>n; switch(n){ case 1: case 2: cout<<'A'; case 3: case 4: cout<<'B'; break; default:cout<<'C'; }
A.显示:A
B.显示:B
C.显示:C
D.显示:AB
第3题:
若有定义:float x=1.5;int a=1,b=3,c=2;则正确的switch语句是().
A.switch(x) { case l.0:printf("*n"); case 2.0:printf("**n");}
B.switch((int)x); { case l:printf("*n"); case 2:printf("**n");}
C.switch(a+b); { case l:printf("*n"); case 2+1:printf("**n");}
D.switch(a+b) { case l:printf("*n"); case c:printf("**n");}
第4题:
若定义:float x;int a,b;,则正确的switch语句是( )。
A.switch(x) { case1.0:cout<<"*\n"; case2.0:cout<<"**\n";
B.switch(x) { case 1.2:cout<<"*\n"; case 3:cout<<"**\n"; }
C.switch(a+b) { case 1.0:cout<<"*\n"; case 1+2:cout<<"**\n ";
D.switch(a+b) { case 1:cout<<"*\n"; case 2:cout<<"**\n";
第5题:
若有定义:float x=1.5;int a=1,b=3,c=2;则正确的switch语句是().
A.switch(x) { case l.0:printf("*n"); case 2.0:printf("**n"); }
B.switch((int)x); { case l:printf("*n"); case 2:printf("**n"); }
C.switch(a+b) { case l:printf("*n"); case 2+1:printf("**n"); }
D.switch(a+b) { case l:printf("*n"); case c:printf("**n"); }