• 2022-06-18
    若int x=10; 执行下列程序后,变量x的正确结果是( )。 switch ( x ) { case 9: x++;
    case 10: x++;
    case 11: x++; default: x++; }
    A: 10
    B: 11
    C: 12
    D: 13
  • D

    内容

    • 0

      中国大学MOOC: 有如下程序段:int x;scanf("%d",&x);switch ( x ) { case 9: x++; break; case 10: x++; case 11: x++; break; default: x++;}如果最初输入的x的值为10,则switch语句结束后x的值为________,

    • 1

      若intx=10;执行下列程序后,变量x的正确结果是。switch(x){case9:x++;case10:x++;case11:x++;break;default:x++;} A: 10 B: 11 C: 12 D: 13

    • 2

      有如下程序段: int x =1, y=1 ; int m , n; m=n=1; switch (m) { case 0 : x=x*2; case 1: { switch (n) { case 1 : x=x*2; case 2 : y=y*2;break; case 3 : x++; } } case 2 : x++;y++; case 3 : x*=2;y*=2;break; default:x++;y++; } 执行完成后,x和y 的值分别为( )。

    • 3

      有以下程序段,输出结果为(     )。 int x=1,y; switch(x): { case 1: y=x++; case 2: y=x++; case 3: y=x++; } printf(“%d ”,y);

    • 4

      #include[stdio.h] main(){ int x=10,y=5; switch(x) { case 1:x++; default:x+=y;case 2:y--;case 3:x--;}printf("x=%d,y=%d\n",x,y);}程序的运行结果为 。