Dim cj(1000) As Integer, n As Integer
Private Sub btncmd1_Click( )
Dim i As Integer, j As Integer
Dim k As Integer ,tmp As Integer
For i = 2 To n
tmp = cj(i)
j = BinarySearch
For k = i To j + 1 Step -1
cj(k) = cj(k - 1)
Next k
cj(k) = tmp
Next i
For i = 1 To n
List1.AddItem Str(cj(i))
Next i
End Sub
Private Sub btncmd2_Click()
Dim i As Integer
i = BinarySearch(Val(Text1.Text), 1, n)
Label2.Caption = "共有" ++ "位同学大于等于该成绩。"
End Sub
Function BinarySearch(key As Integer,i As Integer,j As Integer) As Integer
Dim m As Integer
Do While i <= j
m = (i + j) \ 2
If cj(m) >= key Then
j = m - 1
Else
i = m + 1
End If
Loop
BinarySearch =
End Function
Private Sub Form_Load()
'从数据库获取n个成绩存储在 cj(1) ~cj(n)组中,代码略
End Sub