Private Sub Command1_Click()
Dim n, i, j, temp As Integer
Dim a(1 To 10) As Integer
n = Val(Text1.Text)
Randomize
a(1) = Int(Rnd * 20) + 1
For i = 2 To n
a(i) = Int(Rnd * 20) + 1
If a(i) > a(i - 1) Then
temp = a(i)
bot = 1 : Top = n
Do While bot <= Top
‘(1)
If temp < a(m) Then bot = m + 1 Else Top = m - 1
Loop
For k = n To bot + 1 Step -1
‘(2)
Next k
a(bot) = temp
End If
Next i
For j = 1 To n
List1.AddItem Str(a(j))
Next j
End Sub
以上程序段运行时,为了实现上述功能,加框处代码应改正为:
⑴;⑵。