• 2022-06-01
    下列条件语句中,输出结果与其他语句不同的是
    A: if(a)printf("%d\ n",x);else printf("%d\n",y);
    B: if(a==0)printf("%d\n",y);else printf("%d\n",x);
    C: if(a!=0)printf("%d\ n",x);else printf("%d\n",y);
    D: if(a==0)printf("%d \n",x);else printf("%d\n",y);
  • D

    举一反三

    内容

    • 0

      已知变量x为int类型。下面的条件语句中,有一个与其它三个不等价,它是______。 A: if<br/>( x==1 ) printf(”Yes!\n”);<br/>else printf(“No!\n” ); B: if<br/>( x ) printf(”Yes!\n”);<br/>else printf(“No!\n”<br/>); C: if<br/>( x==0 ) printf(“No!\n”<br/>); else printf(”Yes!\n”); D: if( x!=0 ) printf(”Yes!\n”);<br/>else printf(“No!\n” );

    • 1

      以下二条if语句可合并成一条if语句为______ 。 if(a&lt;=b)x=1; else y=2; if(a&gt;b)printf(“****y=%d\n”,y); else printf(“####x=%d\n”,x);

    • 2

      ‌以下正确的if语句是( )‎ A: if (n>0) printf("%f",n)printf("%f",-n); B: if (n>0){ n=n+m; printf("%f",n); } else printf("%f",-n); C: if (n>0) { n=n+m; printf("%f",n); }; else printf("%f",-n); D: if (n>0) { n=n+m; printf("%f",n) }; else printf("%f",-n);

    • 3

      下列条件语句中,输出结果与其他语句不同的是( )。 A: if ( a ) printf(&quot;%d&quot;, x); else printf(&quot;%d&quot;, y); B: if ( a==0 ) printf(&quot;%d&quot;, y); else printf(&quot;%d&quot;, x); C: if ( a==0 ) printf(&quot;%d&quot;, x); else printf(&quot;%d&quot;, y); D: if ( a!=0 ) printf(&quot;%d&quot;, x); else printf(&quot;%d&quot;, y);

    • 4

      运行下面程序时,从键盘输入"12,34,9&#91;CR&#93;",则输出结果是______. #include &#91;stdio.h&#93; void main( ) { int x,y,z; scanf("%d,%d,%d",&x,&y,&z); if (x<y) if (y<z)printf("%d\n",z); else printf("%d\n",y); else if (x<z)printf("%d\n",z); else printf("%d\n",x); } A: 34 B: 12 C: 9 D: 不确定的值