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 回逐渐 减小????
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 回逐渐 减小????
a每自增一次 b就会减少2
以后考C 你可以闭上眼睛了!!!!!(国内考试均有效)
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;//因为这个
}
}
}
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
}
}
}
{
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;
}
}
}
是因为这个b=b-2;
LZ有前途加油!~~~~~~