实现上述功能的部分VB程序如下,请在划线处填入合适的代码。
Const
n=1000,m=50
Dim
a(1 To n)As Integer, b(1 To m)As Integer
Function
getImax(k As Integer)As Integer
‘在数组元素b(1)~b(k)中找出值最大的元素,返回其下标,代码略
End
Function
Private
Sub Commandl_Click( )
Dim i
As Integer, j As Integer, k As Integer
Dim
na As Integer, nb As Integer, imax As Integer, mean As Integer
‘读取数据分别存入数组a、b,代码略
na=n :
nb=m
imax=getImax(nb)
For
i=1 To m
If a(na)<=
Then
b(imax)=b(nb)
nb=nb-1
If
nb>0 Then imax=getImax(nb)
Else
na=na-1
End
If
Next
i
Do
While nb>0
i=1 :
j=na
imax=
getImax(nb)
Do
While i<=j
mean
=(i+j)\2
If
a(mean)<b(imax) Then i= mean +1 Else j=mean-1
Loop
For
k=na To 1 Step-1
Next
k
a(i+nb-1)=b(imax)
b(imax)=b(nb)
nb=nb-1
Loop
'输出数组a,代码略
End
Sub