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,41 @@
|
|||
' version 23-10-2016
|
||||
' compile with: fbc -s console
|
||||
|
||||
Sub stoogesort(s() As Long, l As Long, r As Long)
|
||||
|
||||
If s(r) < s(l) Then
|
||||
Swap s(r), s(l)
|
||||
End If
|
||||
|
||||
If r - l > 1 Then
|
||||
Var t = (r - l +1) \ 3
|
||||
stoogesort(s(), l , r - t)
|
||||
stoogesort(s(), l + t, r )
|
||||
stoogesort(s(), l , r - t)
|
||||
End If
|
||||
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 "unsorted ";
|
||||
For i = a To b : Print Using "####"; array(i); : Next : Print
|
||||
|
||||
stoogesort(array(), LBound(array), UBound(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