执行语句序列 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
第1题:
当从键盘输入'c'时,以下程序段的输出结果是 。 cin>>n; switch(n) { default: cout<<"errorn";break; case 'a': case 'A':case 'b':case 'B':cout<<"goodn";break; case 'c': case 'C':cout<<"passn"; case 'd': case 'D':cout<<"warnn"; }
第2题:
若有定义: float x=1.5; int a =1,b=3,c=2;则能编译通过的switch语句是()
A.switch(a+b) { case 1: printf("*n"); case 2+1 : printf("**n"); }
B.switch((int)x ) { case 1: printf("*n"); case 2 : printf("**n"); }
C.switch(x ) { case 1.0: printf("*n"); case 2.0 : printf("**n"); }
D.switch(a+b ) { case 1: printf("*n"); case c: printf("**n"); }
E.switch(a+b ) { case 1: printf("*n"); case (int)x: printf("**n"); }
第3题:
执行如下语句序列,不可能出现的情况是: 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
第4题:
1.若有定义:“float x=1.5; int a=1,b=3,c=2;”,则正确的switch语句是 。
A.switch (x) {case 1.0:printf("*n"); case 2.0:printf("**n");}
B.switch ((int)x) ; {case 1:printf("*n"); case 2:printf("**n");}
C.switch (a+b) {case1:printf(**n); case c:printf(**n);}
D.switch (a+b) {case 1:printf("*n"); case 2+1:printf("**n");}
第5题:
若定义: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";
第6题:
执行语句序列: 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
第7题:
若有定义float x=1.5;int a=1,b=3,c=2;,则正确的switch语句是
A.swimh(x) {case 1.0:printf("*\n"); case 2.0:printf("**\n");}
B.switch((int)x); {case 1:printf("*\n"); case 2:printf("**\n");}
C.switch(a+
D. {case 1:pfintf("*\n"); case 2+1:pfintf("**\n");}switch(a-I-{case 1:pfintf("*\n"); case c:printf("**\n");}
第8题:
执行语句序列 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
第9题:
若有定义 : float x=1.5; int a=1,b=3,c=2; 则正确的 switch 语句是
A)
switch(x)
{ case 1.0: printf("*\n");
case 2.0: printf("**\n");}
B)
switch((int)x);
{ case 1: printf("*\n");
case 2: printf("**\n");}
C)
switch(a+b)
{ case 1: printf("*\n");
case 2+1: printf("**\n");}
D)
switch(a+b)
{ case 1: printf("*\n");
case c: printf("**\n");}