Dim A() As Integer
Dim B() As Integer
Dim C() As Integer
Dim d() As Integer
Dim k, n, j, i As Integer
Private Sub cmdRun_Click()
n = Val(InputBox("Введите N"))
m = Val(InputBox("Введите M"))
ReDim A(n)
k = 0
ReDim C(m + n)
ReDim d(m + n)
For i = 1 To n
A(i) = Val(InputBox("Введите значение элемента массива A"))
If A(i) < 0 Then k = k + 1: C(k) = A(i)
Next i
ReDim B(m)
For i = 1 To m
B(i) = Val(InputBox("Введите значение элемента массива B"))
If B(i) < 0 Then k = k + 1: C(k) = B(i)
Next i
'сортировка
For i = 1 To k
d(i) = 0
Next i
For i = 1 To k
j = i - 1
Do While j >= 1
If C(i) < C(j) Then
d(j) = d(j) + 1
Else
d(i) = d(i) + 1
End If
j = j - 1
Loop
Next i
For i = m + n To 1 Step -1
For j = m + n To 1 Step -1
If d(j) = i - 1 And C(j) <> 0 Then Print C(j)
Next j
Next i
End Sub