关于汉诺塔的问题
怎样修改程序使得能够控制汉诺塔移动快慢我是新手啊,请大家帮帮我
Dim pan(10) As Shape
Dim l(3) As Integer
Dim p(3) As Integer
Dim k As Integer
Dim h(3, 10) As Integer
Dim num As Integer
Private Sub Command1_Click()
For i = 1 To num
h(1, i) = i
Next
p(1) = num
k = 0
Call han(num, 1, 2, 3)
s = l(1): l(1) = l(3): l(3) = s
For i = 1 To 3
p(i) = 0
Next
End Sub
Private Sub Form_Activate()
num = Val(Text1.Text)
For i = 1 To num
pan(i).Left = pan(i).Tag
pan(i).Visible = True
Next
For i = num + 1 To 10
pan(i).Visible = False
Next
For i = 1 To 3
l(i) = Line1(i - 1).X1
Next
End Sub
Private Sub Form_Load()
For i = 1 To 10
Set pan(i) = Shape1(i - 1)
pan(i).Tag = pan(i).Left
Next
End Sub
Private Sub han(m As Integer, u As Integer, v As Integer, w As Integer)
If m = 1 Then
Call yidong(u, w)
Else
Call han(m - 1, u, w, v)
Call yidong(u, w)
Call han(m - 1, v, u, w)
End If
End Sub
Private Sub yidong(X As Integer, Y As Integer)
a = p(X)
b = p(Y) + 1
h(Y, b) = h(X, a)
pan(h(Y, b)).Top = 200
Call yianshi(0.1)
pan(h(Y, b)).Left = l(Y) - pan(h(Y, b)).Width / 2
Call yianshi(0.2)
pan(h(Y, b)).Top = 1700 - p(Y) * 100
Call yianshi(0.1)
p(X) = a - 1
p(Y) = b
k = k + 1
Label3.Caption = "移动了" + LTrim(Str(k)) + "次"
Form1.Refresh
End Sub
Private Sub yianshi(pausetime)
Dim start
start = Timer
Do While Timer < start + pausetime
Loop
End Sub
Private Sub Text1_Change()
n = Val(Text1.Text)
If n > 2 And n < 10 Then
Form_Activate
End If
End Sub