小丫编写了一个求中位数的VB程序,功能如下:单击“求中位数”按钮Command1,程序根据输入的n和m,随机产生n个在[0,m]范围内的数。程序运行界面如下所示:
实现上述功能的VB 程序如下:
Dim x(1 To 1000) As Long
Private Sub Command1_Click()
Dim n As Integer, i As Integer, rbound As Integer, mid As Integer
Dim m As Integer, count As Integer
n = Val(Text1.Text)
m = Val(Text2.Text)
List1.Clear
Randomize
For i = 1 To n
x(i) =Int(Rnd * (m + 1)) ' 产生[0,m] 的随机数
List1.AddItem x(i)
Next i
lb = 0
rb = m
Do While lb <rb
mid = (lb + rb) \ 2
①
For i = 1 To n
If ② Then
count = count + 1
End If
Next i
If count > n \ 2 Then
lb = mid + 1
Else
③
End If
Loop
Text3. text = str(rb)
End Sub
程序要实现该功能,画线处应填入的代码为:
①②③