关于插入排序法和合并排序法的VB课程设计代码请哪位仁兄帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/25 01:50:46

Dim a() As Integer
Dim b() As Integer
Dim x_cha() As Integer
Dim x_he() As Integer

Private Sub charu(x() As Integer, y() As Integer)
For i = 0 To UBound(x)
x_cha(i) = x(i)
Next i
For i = 0 To UBound(y)
For j = 0 To UBound(x) + i
If x_cha(j) > y(i) Then Exit For
Next j
For k = UBound(x) + i To j Step -1
x_cha(k + 1) = x_cha(k)
Next k
x_cha(j) = y(i)
Next i
End Sub

Private Sub Command1_Click()
ReDim x_cha(UBound(a) + UBound(b) + 1)
If UBound(a) > UBound(b) Then
charu a(), b()
Else
charu b(), a()
End If
Print "插入排序结果:"
For i = 0 To UBound(x_cha)
Print x_cha(i);
Next i
Print
End Sub

Private Sub Command2_Click()
ap = 0
bp = 0
Do
If ap > UBound(a) Then
For i = bp To UBound(b)
x_he(ap + i) = b(i)
Next i
Exit Do
ElseIf bp > UBound(b) Then
For i = ap