• 2022-06-18
    中国大学MOOC: 若int x=10; 执行下列程序后,变量x的正确结果是 。switch ( x ) { case 9: x++; case 10: x++; case 11: x++; break; default: x++; }
  • 12

    内容

    • 0

      有如下程序段: 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 的值分别为( )。

    • 1

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

    • 2

      #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);}程序的运行结果为 。

    • 3

      执行以下程序段后,输出的结果是______。 int x=2,y=0; switch(x) { case 2: x++;y=x+1; case 1: y=y+1;break; default:x++;y=y+1; } printf("%d,%d\n",x,y); A: 3,5 B: 3,4 C: 2,0 D: 3,1

    • 4

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