如果语句被跳过

时间:2016-11-11 21:01:04

标签: c if-statement

创建程序,显示比 x 更小/更大的整数。整数按升序排列。 (1,2,3 ......) 适用于较少语句(尝试使用max int 'zzz'), 但如果更多,就像在我的情况下(直到' zzzzzzzzzzzzz '),它开始时忽略行(更多整数,更多)线被忽略了)。 需要代码(下面的链接)来显示所有整数。

if( a < x)      {printf("%ld\n", a); }
if( b < x)      {printf("%ld\n", b); }
if( c < x)      {printf("%ld\n", c); }

printf("\nxxxxxxxxx\n\n");

if( a > x)      {printf("%ld\n", a); }
if( b > x)      {printf("%ld\n", b); }
if( c > x)      {printf("%ld\n", c); }
  

如果给定整数:a = 1,b = 2,x = 3,c = 4

     

然后我们回来:

>                     1
>                     2
>                     xxxxxxxxxx
>                     4
  

然而,当我们添加更多数字(x保持不变)时,较小的数字开始   没有出现在命令提示符下。

以下是代码(应以 1 开头,但不起作用):

  

[https://docs.google.com/document/d/1iDP8a03XhPeNeyonLHgD_vKctiLJqu0sw5tLVUCQPy0/edit?usp=sharing][1]   (Ctrl + A应该做,太大了,不能到这里)

以下是工作代码(长度不同,工作正常):

#include <stdio.h>
#include <stdlib.h>

int main()
{


long int    a   =   1   ;
long int    b   =   2   ;
long int    c   =   3   ;
long int    d   =   4   ;
long int    e   =   5   ;
long int    f   =   6   ;
long int    g   =   7   ;
long int    h   =   8   ;
long int    i   =   9   ;
long int    j   =   10  ;
long int    k   =   11  ;
long int    l   =   12  ;
long int    m   =   13  ;
long int    n   =   14  ;
long int    o   =   15  ;
long int    p   =   16  ;
long int    q   =   17  ;
long int    r   =   18  ;
long int    s   =   19  ;
long int    t   =   20  ;
long int    u   =   21  ;
long int    v   =   22  ;
long int    w   =   23  ;
long int    x   =   24  ;
long int    y   =   25  ;
long int    z   =   26  ;
long int    aa  =   27  ;
long int    bb  =   28  ;
long int    cc  =   29  ;
long int    dd  =   30  ;
long int    ee  =   31  ;
long int    ff  =   32  ;
long int    gg  =   33  ;
long int    hh  =   34  ;
long int    ii  =   35  ;
long int    jj  =   36  ;
long int    kk  =   37  ;
long int    ll  =   38  ;
long int    mm  =   39  ;
long int    nn  =   40  ;
long int    oo  =   41  ;
long int    pp  =   42  ;
long int    qq  =   43  ;
long int    rr  =   44  ;
long int    ss  =   45  ;
long int    tt  =   46  ;
long int    uu  =   47  ;
long int    vv  =   48  ;
long int    ww  =   49  ;
long int    xx  =   50  ;
long int    yy  =   51  ;
long int    zz  =   52  ;
long int    aaa =   53  ;
long int    bbb =   54  ;
long int    ccc =   55  ;
long int    ddd =   56  ;
long int    eee =   57  ;
long int    fff =   58  ;
long int    ggg =   59  ;
long int    hhh =   60  ;
long int    iii =   61  ;
long int    jjj =   62  ;
long int    kkk =   63  ;
long int    lll =   64  ;
long int    mmm =   65  ;
long int    nnn =   66  ;
long int    ooo =   67  ;
long int    ppp =   68  ;
long int    qqq =   69  ;
long int    rrr =   70  ;
long int    sss =   71  ;
long int    ttt =   72  ;
long int    uuu =   73  ;
long int    vvv =   74  ;
long int    www =   75  ;
long int    xxx =   76  ;
long int    yyy =   77  ;
long int    zzz =   78  ;


if( a   <x){printf("%ld\n", a   );}
if( b   <x){printf("%ld\n", b   );}
if( c   <x){printf("%ld\n", c   );}
if( d   <x){printf("%ld\n", d   );}
if( e   <x){printf("%ld\n", e   );}
if( f   <x){printf("%ld\n", f   );}
if( g   <x){printf("%ld\n", g   );}
if( h   <x){printf("%ld\n", h   );}
if( i   <x){printf("%ld\n", i   );}
if( j   <x){printf("%ld\n", j   );}
if( k   <x){printf("%ld\n", k   );}
if( l   <x){printf("%ld\n", l   );}
if( m   <x){printf("%ld\n", m   );}
if( n   <x){printf("%ld\n", n   );}
if( o   <x){printf("%ld\n", o   );}
if( p   <x){printf("%ld\n", p   );}
if( q   <x){printf("%ld\n", q   );}
if( r   <x){printf("%ld\n", r   );}
if( s   <x){printf("%ld\n", s   );}
if( t   <x){printf("%ld\n", t   );}
if( u   <x){printf("%ld\n", u   );}
if( v   <x){printf("%ld\n", v   );}
if( w   <x){printf("%ld\n", w   );}
if( x   <x){printf("%ld\n", x   );}
if( y   <x){printf("%ld\n", y   );}
if( z   <x){printf("%ld\n", z   );}
if( aa  <x){printf("%ld\n", aa  );}
if( bb  <x){printf("%ld\n", bb  );}
if( cc  <x){printf("%ld\n", cc  );}
if( dd  <x){printf("%ld\n", dd  );}
if( ee  <x){printf("%ld\n", ee  );}
if( ff  <x){printf("%ld\n", ff  );}
if( gg  <x){printf("%ld\n", gg  );}
if( hh  <x){printf("%ld\n", hh  );}
if( ii  <x){printf("%ld\n", ii  );}
if( jj  <x){printf("%ld\n", jj  );}
if( kk  <x){printf("%ld\n", kk  );}
if( ll  <x){printf("%ld\n", ll  );}
if( mm  <x){printf("%ld\n", mm  );}
if( nn  <x){printf("%ld\n", nn  );}
if( oo  <x){printf("%ld\n", oo  );}
if( pp  <x){printf("%ld\n", pp  );}
if( qq  <x){printf("%ld\n", qq  );}
if( rr  <x){printf("%ld\n", rr  );}
if( ss  <x){printf("%ld\n", ss  );}
if( tt  <x){printf("%ld\n", tt  );}
if( uu  <x){printf("%ld\n", uu  );}
if( vv  <x){printf("%ld\n", vv  );}
if( ww  <x){printf("%ld\n", ww  );}
if( xx  <x){printf("%ld\n", xx  );}
if( yy  <x){printf("%ld\n", yy  );}
if( zz  <x){printf("%ld\n", zz  );}
if( aaa <x){printf("%ld\n", aaa );}
if( bbb <x){printf("%ld\n", bbb );}
if( ccc <x){printf("%ld\n", ccc );}
if( ddd <x){printf("%ld\n", ddd );}
if( eee <x){printf("%ld\n", eee );}
if( fff <x){printf("%ld\n", fff );}
if( ggg <x){printf("%ld\n", ggg );}
if( hhh <x){printf("%ld\n", hhh );}
if( iii <x){printf("%ld\n", iii );}
if( jjj <x){printf("%ld\n", jjj );}
if( kkk <x){printf("%ld\n", kkk );}
if( lll <x){printf("%ld\n", lll );}
if( mmm <x){printf("%ld\n", mmm );}
if( nnn <x){printf("%ld\n", nnn );}
if( ooo <x){printf("%ld\n", ooo );}
if( ppp <x){printf("%ld\n", ppp );}
if( qqq <x){printf("%ld\n", qqq );}
if( rrr <x){printf("%ld\n", rrr );}
if( sss <x){printf("%ld\n", sss );}
if( ttt <x){printf("%ld\n", ttt );}
if( uuu <x){printf("%ld\n", uuu );}
if( vvv <x){printf("%ld\n", vvv );}
if( www <x){printf("%ld\n", www );}
if( xxx <x){printf("%ld\n", xxx );}
if( yyy <x){printf("%ld\n", yyy );}
if( zzz <x){printf("%ld\n", zzz );}


printf("\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\n");


if( a   >x){printf("%ld\n", a   );}
if( b   >x){printf("%ld\n", b   );}
if( c   >x){printf("%ld\n", c   );}
if( d   >x){printf("%ld\n", d   );}
if( e   >x){printf("%ld\n", e   );}
if( f   >x){printf("%ld\n", f   );}
if( g   >x){printf("%ld\n", g   );}
if( h   >x){printf("%ld\n", h   );}
if( i   >x){printf("%ld\n", i   );}
if( j   >x){printf("%ld\n", j   );}
if( k   >x){printf("%ld\n", k   );}
if( l   >x){printf("%ld\n", l   );}
if( m   >x){printf("%ld\n", m   );}
if( n   >x){printf("%ld\n", n   );}
if( o   >x){printf("%ld\n", o   );}
if( p   >x){printf("%ld\n", p   );}
if( q   >x){printf("%ld\n", q   );}
if( r   >x){printf("%ld\n", r   );}
if( s   >x){printf("%ld\n", s   );}
if( t   >x){printf("%ld\n", t   );}
if( u   >x){printf("%ld\n", u   );}
if( v   >x){printf("%ld\n", v   );}
if( w   >x){printf("%ld\n", w   );}
if( x   >x){printf("%ld\n", x   );}
if( y   >x){printf("%ld\n", y   );}
if( z   >x){printf("%ld\n", z   );}
if( aa  >x){printf("%ld\n", aa  );}
if( bb  >x){printf("%ld\n", bb  );}
if( cc  >x){printf("%ld\n", cc  );}
if( dd  >x){printf("%ld\n", dd  );}
if( ee  >x){printf("%ld\n", ee  );}
if( ff  >x){printf("%ld\n", ff  );}
if( gg  >x){printf("%ld\n", gg  );}
if( hh  >x){printf("%ld\n", hh  );}
if( ii  >x){printf("%ld\n", ii  );}
if( jj  >x){printf("%ld\n", jj  );}
if( kk  >x){printf("%ld\n", kk  );}
if( ll  >x){printf("%ld\n", ll  );}
if( mm  >x){printf("%ld\n", mm  );}
if( nn  >x){printf("%ld\n", nn  );}
if( oo  >x){printf("%ld\n", oo  );}
if( pp  >x){printf("%ld\n", pp  );}
if( qq  >x){printf("%ld\n", qq  );}
if( rr  >x){printf("%ld\n", rr  );}
if( ss  >x){printf("%ld\n", ss  );}
if( tt  >x){printf("%ld\n", tt  );}
if( uu  >x){printf("%ld\n", uu  );}
if( vv  >x){printf("%ld\n", vv  );}
if( ww  >x){printf("%ld\n", ww  );}
if( xx  >x){printf("%ld\n", xx  );}
if( yy  >x){printf("%ld\n", yy  );}
if( zz  >x){printf("%ld\n", zz  );}
if( aaa >x){printf("%ld\n", aaa );}
if( bbb >x){printf("%ld\n", bbb );}
if( ccc >x){printf("%ld\n", ccc );}
if( ddd >x){printf("%ld\n", ddd );}
if( eee >x){printf("%ld\n", eee );}
if( fff >x){printf("%ld\n", fff );}
if( ggg >x){printf("%ld\n", ggg );}
if( hhh >x){printf("%ld\n", hhh );}
if( iii >x){printf("%ld\n", iii );}
if( jjj >x){printf("%ld\n", jjj );}
if( kkk >x){printf("%ld\n", kkk );}
if( lll >x){printf("%ld\n", lll );}
if( mmm >x){printf("%ld\n", mmm );}
if( nnn >x){printf("%ld\n", nnn );}
if( ooo >x){printf("%ld\n", ooo );}
if( ppp >x){printf("%ld\n", ppp );}
if( qqq >x){printf("%ld\n", qqq );}
if( rrr >x){printf("%ld\n", rrr );}
if( sss >x){printf("%ld\n", sss );}
if( ttt >x){printf("%ld\n", ttt );}
if( uuu >x){printf("%ld\n", uuu );}
if( vvv >x){printf("%ld\n", vvv );}
if( www >x){printf("%ld\n", www );}
if( xxx >x){printf("%ld\n", xxx );}
if( yyy >x){printf("%ld\n", yyy );}
if( zzz >x){printf("%ld\n", zzz );}


    return 0;
}

1 个答案:

答案 0 :(得分:1)

If语句正是出于此目的 - 如果条件不满足,则跳过 (=如果它评估为false)。

你的第二个if语句块正是这个,因为你告诉你按访问顺序排序了数字:a非常小,所以条件为a > xfalseb也许还不够大。最终c已经足够 大于 x所以从这一点开始不会跳过if语句