?? form1.frm
字號(hào):
VERSION 5.00
Begin VB.Form Form1
Caption = "折半查找"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 255
Left = 3240
TabIndex = 1
Top = 2160
Width = 975
End
Begin VB.TextBox Text1
Height = 375
Left = 840
TabIndex = 0
Text = "Text1"
Top = 480
Width = 2055
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim a(1 To 15) As Integer
a(1) = 1
a(2) = 3: a(3) = 4: a(4) = 7: a(5) = 11
a(6) = 23: a(7) = 33: a(8) = 35: a(9) = 57: a(10) = 111
a(11) = 211: a(12) = 213: a(13) = 333: a(14) = 347: a(15) = 518
Text1.Text = Search3(a, 1, 15, 518)
End Sub
Function Search3(a() As Integer, intStart As Integer, intEnd As Integer, b As Integer) As Integer
Dim m As Integer, n As Integer, int1 As Integer
m = intStart
n = intEnd
int1 = (m + n) \ 2
If b < a(int1) Then
n = int1 - 1
Search3 = Search3(a, m, n, b)
ElseIf b > a(int1) Then
m = int1 + 1
Search3 = Search3(a, m, n, b)
Else
Search3 = int1
End If
If m = n Then
Search3 = m
End If
End Function
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -