程序界面如图所示:
Dim a(1 To 10)As Integer
Function find(L As Integer,R As Integer,key As Integer)As Integer
If L>R Then
find=0:Exit Functionhp
ElseIf a(L)>=key Then
find=L:Exit Function
Else
①
If a(M)<key Thenhp
find=find(M+1,R,key)
ElseIf ② Then
find=find(L,M-1,key)
Else
find=M
End If
End If
End Function
Private Sub Command1 Click()
Dim k As Integer
Dim P As Integer
k=Val(Text1.Text)
③
Text2.Text=a(P)
Text3.Text=Str(P)
If p=0 Then
Text2.Text=“无”
End If
End Sub
Private Sub Form Load()
a(1)=3:a(2)=3:a(3)=3:a(4)=4:a(5)=7:a(6)=7
a(7)=10:a(8)=13:a(9)=19:a(10)=21
For i=1 To 10
List1.AddItem Str(a(i))
Next i
End Sub
① ② ③