下面程序段的输出结果是(  )。 public class Test t public static void main(String[] args) { int x=0; for (int

admin2013-03-01  36

问题 下面程序段的输出结果是(  )。     public class Test t        public static void main(String[] args) {            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);        }    }

选项 A、36
B、48
C、144
D、15

答案D

解析 题目中是一个三个循环的嵌套,但是每次循环时,x都将重新赋值,所以只计算最后一次即可,x=3,执行了两次x=x+6,所以x=15,选D。
转载请注明原文地址:https://kaotiyun.com/show/p32p777K
0

最新回复(0)