public class Test { /**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
int x=0;
for(int i=1;i<=4;i++){
x=4;
for(int j=1;j<=3;j++){
x=3;
for(int k=1;k<=2;k++){
x=x+6;
}
}
}
System.out.println(x); }}
请具体分析求解过程

解决方案 »

  1.   

    与这个效果是一样的int x = 0;
    x = 4;
    x = 3;
    for(int k = 1; k <= 2; k++) {
      x = x + 6;
    }
    System.out.println(x); 
      

  2.   

    等价于:
    public class Test { public static void main(String[] args) {
    int x = 0;
    for (int i = 1; i <= 1; i++) {
    x = 4;
    for (int j = 1; j <= 1; j++) {
    x = 3;
    for (int k = 1; k <= 2; k++) {
    x = x + 6;
    }
    }
    }
    System.out.println(x);
    }
    }
      

  3.   

    j层循环执行完后x=3,k循环执行两次,第一次结果为9,后来变成15.
      

  4.   

    public class Test {
       public static void main(String[] args){
    // TODO Auto-generated method stub 
    int x=0; 
    for(int i=1;i <=4;i++){ 
    x=1; 
    for(int j=1;j <=3;j++){ 
    x=x+2; 
    for(int k=1;k <=2;k++){ 
    x=x+3; 



    System.out.println(x); 
       }
    }
    这个看懂,那个就明白了~~~