class blocktest{
public static void main (String args[])
{int a,b;
  b=20;
  for(a=0;a<10;a++){
   System.out.println("this is a:"+a);
   System.out.println("this is b:"+b);
   b=b-2;
  }
}
}
 运行结果:
this is a:0
this is b:20
this is a:1
this is b:18
this is a:2
this is b:16
this is a:3
this is b:14
this is a:4
this is b:12
this is a:5
this is b:10
this is a:6
this is b:8
this is a:7
this is b:6
this is a:8
this is b:4
this is a:9
this is b:2
Press any key to continue...
为什么b 回逐渐 减小????

解决方案 »

  1.   

    因为 b=b-2啊
    a每自增一次 b就会减少2
      

  2.   

    每执行一次循环,就先输出a和b的值,然后让b减2,然后再把这个值赋给b,既b=b-2,这时b的值和原来比就减少了2,循环一直执行到条件不满足为止。所以b的值也就一直在减少。
      

  3.   

    LZ去看谭的C吧   再把一本配套习题全做完!
      以后考C 你可以闭上眼睛了!!!!!(国内考试均有效)
      

  4.   

    应为b=b-2;在for循环体内,所以每循环一次都要执行一次b-2,再赋值给b,直到不满足条件a<10
      

  5.   

    class blocktest{
    public static void main (String args[])
    {int a,b;
      b=20;
      for(a=0;a<10;a++){
      System.out.println("this is a:"+a);
      System.out.println("this is b:"+b);
      b=b-2;//因为这个
      }
    }
    }
      

  6.   

    class blocktest{
    public static void main (String args[])
    {int a,b;
      b=20;
      for(a=0;a<10;a++){
      System.out.println("this is a:"+a);
      System.out.println("this is b:"+b);
      b=b-2;           //它每次循环都执行一次 -2
      }
    }
    }
      

  7.   

    public class ad
    {
       public static void main (String[] args)
           {int b=20;
                  
          for(int a=0;a<10;a++)
                 {
                     System.out.println("this is a:"+a);
                     System.out.println("this is b:"+b);
                     b=b-2;
                  }
            }
    }
      

  8.   

    哈哈我也能回答问题了
    是因为这个b=b-2;
    LZ有前途加油!~~~~~~