For a = 1 To 2For b = 1 To aFor c = b To 5d = d + 1
问题描述:
For a = 1 To 2For b = 1 To aFor c = b To 5d = d + 1
Private Sub Form_load()
Form1.show
d = 0
For a = 1 To 2
For b = 1 To a
For c = b To 5
d = d + 1
Next c
Next b
Next a
Print d
End Sub
结果如下:
14
能解释下是怎么得到的14吗?
答
循环
a=1 for b=1 to 1
b=1 for c=1 to 5
c=1
d=d+1=0+1=1
c=2
d=1+1=2
c=3
d=2+1=3
c=4
d=3+1=4
c=5
d=4+1=5
c完
b完
a=2 for b=1 to 2
b=1 for c=1 to 5
c=1
d=5+1=6
c=2
d=7
c=3
d=8
c=4
d=9
c=5
d=10
c完
b=2 for c=2 to 5
c=2
d=10+1=11
c=3
d=12
c=4
d=13
c=5
d=14
c完
b完
a完
print d 显示14