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,58 @@
|
|||
' version 21-10-2016
|
||||
' compile with: fbc -s console
|
||||
' compile with: fbc -s console -exx (for bondry check on the array's)
|
||||
' not very well suited for large numbers and large array's
|
||||
' positive numbers only
|
||||
|
||||
Sub sandman(sleepy() As ULong)
|
||||
Dim As Long lb = LBound(sleepy)
|
||||
Dim As Long ub = UBound(sleepy)
|
||||
Dim As Long i, count = ub
|
||||
Dim As Double wakeup(lb To ub)
|
||||
Dim As Double t = Timer
|
||||
|
||||
For i = lb To ub
|
||||
wakeup(i) = sleepy(i) +1 + t
|
||||
Next
|
||||
|
||||
Do
|
||||
t = Timer
|
||||
For i = lb To ub
|
||||
If wakeup(i) <= t Then
|
||||
Print Using "####";sleepy(i);
|
||||
wakeup(i) = 1e9 ' mark it as used
|
||||
count = count -1
|
||||
End If
|
||||
Next
|
||||
Sleep (1 - (Timer - t)) * 300, 1 ' reduce CPU load
|
||||
Loop Until count < lb
|
||||
|
||||
End Sub
|
||||
|
||||
' ------=< MAIN >=------
|
||||
|
||||
Dim As ULong i, arr(10)
|
||||
Dim As ULong lb = LBound(arr)
|
||||
Dim As ULong ub = UBound(arr)
|
||||
|
||||
Randomize Timer
|
||||
For i = lb To ub -1 ' leave last one zero
|
||||
arr(i) = Int(Rnd * 10) +1
|
||||
Next
|
||||
|
||||
Print "unsorted ";
|
||||
For i = lb To ub
|
||||
Print Using "####";arr(i);
|
||||
Next
|
||||
Print : Print
|
||||
|
||||
Print " sorted ";
|
||||
sandman(arr())
|
||||
|
||||
Print : 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