死囚器官:sos`~~!求助一VB高人~~

来源:百度文库 编辑:高考问答 时间:2024/05/02 08:56:27
请教高手,能给我详细解析吗?
for a=1 to 2
for b=1 to a
for c=b to 2
i = i+1
next
next
next
print i
执行上面三重循环后,i的值
可以计算的
一般i=0开始的`

1.当a=1

for b=1 to a
for c=b to 2
i = i+1
next
next
变为:
for b=1 to 1
for c=b to 2
i = i+1
next
next
就是执行1次的
for c=b to 2
i = i+1
next

for c=1 to 2
i = i+1
next
i=0+1
i=1+1
i=2
-----------------------------------------
2.当 a=2 时

for b=1 to a
for c=b to 2
i = i+1
next
next
变为:
for b=1 to 2
for c=b to 2
i = i+1
next
next
就是执行2次的
for c=b to 2
i = i+1
next

A.
for c=1 to 2
i = i+1
next
i=2+1
i=3+1
i=4
B.
for c=2 to 2
i = i+1
next
i=4+1
i=5
最后输出 5

无法计算,i的初始值并没说明

无法计算,在第二个循环的时候都停止了