求解一道VB private sub command1_click() for i = 1 to 4 x=4 for j =1 to 3 x=3 for k=1 to 2 x=x+6 补接上:next knext jnext iprint xend sub
求解一道VB private sub command1_click() for i = 1 to 4 x=4 for j =1 to 3 x=3 for k=1 to 2 x=x+6 补接上:next knext jnext iprint xend sub
求解一道VB private sub command1_click() for i = 1 to 4 x=4 for j =1 to 3 x=3 for k=1 to 2 x=x+6 补
接上:
next k
next j
next i
print x
end sub
求解一道VB private sub command1_click() for i = 1 to 4 x=4 for j =1 to 3 x=3 for k=1 to 2 x=x+6 补接上:next knext jnext iprint xend sub
首先x=4是个干扰项,因为在j循环又对i重新赋值3,你可以把x=4去掉试试,不影响结果,
从最外层循环体for i= 1 to 4开始,
i=1,x=4,这时j=1,x=3,k=1,x=x+6=9
k=2, x=x(上一个)+6=9+6=15
j=2,k=1
k=2
j=3,k=1
k=2
(往后的循环并没有改变x的值,所以也不会改变表达式x=x+6=15的值)
上面说过i 循环里的x=4其实可以删去,所以也不影响x=x+6=15的值,结果就是15了