Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
Sub Lis(arr() As Integer)
|
||||
Dim As Integer lb = Lbound(arr), ub = Ubound(arr)
|
||||
Dim As Integer i, lo, hi, mitad, newl, l = 0
|
||||
Dim As Integer p(ub), m(ub)
|
||||
|
||||
For i = lb To ub
|
||||
lo = 1
|
||||
hi = l
|
||||
Do While lo <= hi
|
||||
mitad = Int((lo+hi)/2)
|
||||
If arr(m(mitad)) < arr(i) Then
|
||||
lo = mitad + 1
|
||||
Else
|
||||
hi = mitad - 1
|
||||
End If
|
||||
Loop
|
||||
newl = lo
|
||||
p(i) = m(newl-1)
|
||||
m(newl) = i
|
||||
If newL > l Then l = newl
|
||||
Next i
|
||||
|
||||
Dim As Integer res(l)
|
||||
Dim As Integer k = m(l)
|
||||
For i = l-1 To 0 Step - 1
|
||||
res(i) = arr(k)
|
||||
k = p(k)
|
||||
Next i
|
||||
|
||||
For i = Lbound(res) To Ubound(res)-1
|
||||
Print res(i); " ";
|
||||
Next i
|
||||
End Sub
|
||||
|
||||
Dim As Integer arrA(5) => {3,2,6,4,5,1}
|
||||
Lis(arrA())
|
||||
Print
|
||||
Dim As Integer arrB(15) => {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}
|
||||
Lis(arrB())
|
||||
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue