下列程序执行以后,输出的结果是

来源:百度知道 编辑:UC知道 时间:2024/06/19 00:49:43
public class ex14 {
public static void main(String[] args) {
int j=0;
for(int i=3;i>0;i--)
}
j+=i;
int x=2;
while(x<j){
x+=1;
System.out.print(x);
}
}
}

A)35556666 B)3555 C)33453456 D)345

解释一下过程

两层循环
先for
i=3,j=j+i,则j=3
再while
x=2<j=3
x=x+1-->x=3 输出
因为x=2<j=3
所以还要while此时x=3==j=3所以不输出
跳出while 再for一次
i--后,i=2
j=i+j=2+3=5
再进入while x值在while外,所以还是2开始
当x==j=5时跳出
......