Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,87 @@
|
|||
' version 21-10-2016
|
||||
' compile with: fbc -s console
|
||||
' for boundary checks on array's compile with: fbc -s console -exx
|
||||
|
||||
Sub compsort(bs() As Long)
|
||||
' sort from lower bound to the highter bound
|
||||
' array's can have subscript range from -2147483648 to +2147483647
|
||||
Dim As Long lb = LBound(bs)
|
||||
Dim As Long ub = UBound(bs)
|
||||
Dim As Long gap = ub - lb
|
||||
Dim As Long done, i
|
||||
|
||||
Do
|
||||
gap = Int (gap / 1.3)
|
||||
If gap < 1 Then gap = 1
|
||||
done = 0
|
||||
For i = lb To ub - gap
|
||||
If bs(i) > bs(i + gap) Then
|
||||
Swap bs(i), bs(i + gap)
|
||||
done = 1
|
||||
End If
|
||||
Next
|
||||
Loop Until ((gap = 1) And (done = 0))
|
||||
|
||||
End Sub
|
||||
|
||||
Sub comp11sort(bs() As Long)
|
||||
' sort from lower bound to the higher bound
|
||||
' array's can have subscript range from -2147483648 to +2147483647
|
||||
Dim As Long lb = LBound(bs)
|
||||
Dim As Long ub = UBound(bs)
|
||||
Dim As Long gap = ub - lb
|
||||
Dim As Long done, i
|
||||
|
||||
Do
|
||||
gap = Int(gap / 1.24733)
|
||||
If gap = 9 Or gap = 10 Then
|
||||
gap = 11
|
||||
ElseIf gap < 1 Then
|
||||
gap = 1
|
||||
End If
|
||||
done = 0
|
||||
For i = lb To ub - gap
|
||||
If bs(i) > bs(i + gap) Then
|
||||
Swap bs(i), bs(i + gap)
|
||||
done = 1
|
||||
End If
|
||||
Next
|
||||
Loop Until ((gap = 1) And (done = 0))
|
||||
|
||||
End Sub
|
||||
|
||||
' ------=< MAIN >=------
|
||||
|
||||
Dim As Long i, array(-7 To 7)
|
||||
|
||||
Dim As Long a = LBound(array), b = UBound(array)
|
||||
|
||||
Randomize Timer
|
||||
For i = a To b : array(i) = i : Next
|
||||
For i = a To b ' little shuffle
|
||||
Swap array(i), array(Int(Rnd * (b - a +1)) + a)
|
||||
Next
|
||||
|
||||
Print "normal comb sort"
|
||||
Print "unsorted ";
|
||||
For i = a To b : Print Using "####"; array(i); : Next : Print
|
||||
compsort(array()) ' sort the array
|
||||
Print " sorted ";
|
||||
For i = a To b : Print Using "####"; array(i); : Next : Print
|
||||
|
||||
Print
|
||||
Print "comb11 sort"
|
||||
For i = a To b ' little shuffle
|
||||
Swap array(i), array(Int(Rnd * (b - a +1)) + a)
|
||||
Next
|
||||
Print "unsorted ";
|
||||
For i = a To b : Print Using "####"; array(i); : Next : Print
|
||||
comp11sort(array()) ' sort the array
|
||||
Print " sorted ";
|
||||
For i = a To b : Print Using "####"; array(i); : Next : Print
|
||||
|
||||
' empty keyboard buffer
|
||||
While Inkey <> "" : Wend
|
||||
Print : Print "hit any key to end program"
|
||||
Sleep
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue