执行语句序列: int n; cin>>n; switch(n) { case 1: case 2:cout<<'1'; case 3: case 4:cout<<'2';break; default:cout<<'3'; }时,若从键盘输入1,则屏幕显示______ 。A.1B.2C.3D.12

题目

执行语句序列: 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


相似考题
更多“执行语句序列:int n;cin>>n;switch(n) { case 1: case 2:cout<<'1'; case 3: case 4:cout<<'2';b ”相关问题
  • 第1题:

    若定义: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";


    正确答案:D

  • 第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


    显示:A

  • 第3题:

    当从键盘输入'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"; }


    right

  • 第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");}


    B

  • 第5题:

    若有定义: 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"); }


    (x%=y)-(y%=5)