• 2021-04-14
    若有float x; int a,b; ,下面四条switch语句中正确的有( )条。 switch(x) { case x=1.0: printf(“Y”); case x=2.0: printf(“N”); } switch(a) { case a=1: printf(“Y”); case a=2: printf(“N”); } switch(b) { case b==1: printf(“Y”); case b==2: printf(“N”); } switch(x) { case 1.0: printf(“Y”); case 2.0: printf(“N”); }
  • 1

    举一反三

    内容

    • 0

      int main()执行结果是(){int x=2,y=1; switch(x) { case 1: y=x ; break; case 2: y=-x ; case 3: y=x*3 ; break; case 4: y=4*x; } printf(“%d\n”,y);}

    • 1

      1、main(){ int x=2,y;switch(x){ case 1: y=x ; break;case 2: y=-x ;case 3: y=x*3 ; break;case 4: y=4*x;}printf(“%d\n”,y);}程序运行结果:__________________

    • 2

      若有定义:floatx=1.5;inta=1,b=3,c=2;则正确的switch语句是( )。 A: switch(a+b) <br> { case 1:printf("*\n"); <br> case 2+1:printf("**\n");} B: switch((int)x);<br>{case1:printf("*\n");<br>case2:printf("**\n");} C: switch(x)<br>{case1.0:printf("*\n");<br>case2.0:printf("**\n");} D: switch(a+b)<br>{case1:printf("*\n");<br>casec:printf("**\n");}

    • 3

      运行以下程序段,并输入1,则输出结果是( )。 int x; printf("请输入一个0-2的整数:"); scanf("%d",&x); switch(x) { case 0:printf("输入0。\n"); case 1:printf("输入1。\n"); case 2:printf("输入2。\n"); default:printf("输入错误! \n"); }

    • 4

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