高分求解vb题,在线等,结果为123141,关键是后面的141三个数字是如何得出的,求详解!!!!!!!!!!
PrivateSubForm_click()Dima(5)Fori=0To4a(i)=i+1t=i+1Ift=3ThenPrinta(i)a(t-1)=a(i-2)Els...
Private Sub Form_click()
Dim a(5)
For i = 0 To 4
a(i) = i + 1
t = i + 1
If t = 3 Then
Print a(i)
a(t - 1) = a(i - 2)
Else
a(t) = a(i)
End If
If i = 3 Then a(i + 1) = a(t - 4)
a(4) = 1
Print a(i)
Next i
End Sub 展开
Dim a(5)
For i = 0 To 4
a(i) = i + 1
t = i + 1
If t = 3 Then
Print a(i)
a(t - 1) = a(i - 2)
Else
a(t) = a(i)
End If
If i = 3 Then a(i + 1) = a(t - 4)
a(4) = 1
Print a(i)
Next i
End Sub 展开
2个回答
展开全部
先把每一句编号:
(1)Dim a(5)
(2) For i = 0 To 4
(3) a(i) = i + 1
(4) t = i + 1
(5) If t = 3 Then
(6) Print a(i)
(7) a(t - 1) = a(i - 2)
(8) Else
(9) a(t) = a(i)
(10) End If
(11) If i = 3 Then a(i + 1) = a(t - 4)
(12) a(4) = 1
(13) Print a(i)
(14) Next i
程序过程是这样的(每行最前面括号内的数字f都是执行的语句编号):
(1)执行后结果:a(0)=a(1)=a(2)=a(3)=a(4)=a(5)=0
(2)执行后结果:i=0
(3)a(i)=a(0)=i+1=0+1=1,执行后结果:a(0)=1
(4) t=i+1=0+1=1,执行后结果:t=1
(5)判断t=3?,不成立,执行(8)
(8、9)a(t)=a(i),即a(3)=a(0)=1,执行后结果:a(3)=1
(10、11)判断i=3?,不成立。
(12)执行后结果:a(4)=1
(13)打印a(i),i=0,a(i)=a(0)=1,执行后结果:打印“1”............................[1]
(14)i=1,返回到(2)
(2、3)a(i)=i+1,执行后结果:a(1)=1+1=2
(4)t=i+1,执行后结果:t=1+1=2
(5)t=3?,不成立,转至(8)
(8、9)a(t)=a(i),因t=2、i=1,a(2)=a(1)=2
(10、11)判断i=3?,不成立。
(12)执行后结果:a(4)=1
(13)打印a(i),i=1,a(i)=a(1)=2,执行后结果:打印“2”............................[2]
(1)Dim a(5)
(2) For i = 0 To 4
(3) a(i) = i + 1
(4) t = i + 1
(5) If t = 3 Then
(6) Print a(i)
(7) a(t - 1) = a(i - 2)
(8) Else
(9) a(t) = a(i)
(10) End If
(11) If i = 3 Then a(i + 1) = a(t - 4)
(12) a(4) = 1
(13) Print a(i)
(14) Next i
程序过程是这样的(每行最前面括号内的数字f都是执行的语句编号):
(1)执行后结果:a(0)=a(1)=a(2)=a(3)=a(4)=a(5)=0
(2)执行后结果:i=0
(3)a(i)=a(0)=i+1=0+1=1,执行后结果:a(0)=1
(4) t=i+1=0+1=1,执行后结果:t=1
(5)判断t=3?,不成立,执行(8)
(8、9)a(t)=a(i),即a(3)=a(0)=1,执行后结果:a(3)=1
(10、11)判断i=3?,不成立。
(12)执行后结果:a(4)=1
(13)打印a(i),i=0,a(i)=a(0)=1,执行后结果:打印“1”............................[1]
(14)i=1,返回到(2)
(2、3)a(i)=i+1,执行后结果:a(1)=1+1=2
(4)t=i+1,执行后结果:t=1+1=2
(5)t=3?,不成立,转至(8)
(8、9)a(t)=a(i),因t=2、i=1,a(2)=a(1)=2
(10、11)判断i=3?,不成立。
(12)执行后结果:a(4)=1
(13)打印a(i),i=1,a(i)=a(1)=2,执行后结果:打印“2”............................[2]
追问
后面的几个呢?
追答
哈,太长了,只写了一部分。现在忙着加班,后面的请稍等再给你写。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询