Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,115 @@
|
|||
rem bubble sort benchmark example
|
||||
rem compile with FTCBASIC
|
||||
|
||||
use time.inc
|
||||
use random.inc
|
||||
|
||||
define const size = 32000
|
||||
|
||||
dim list[size]
|
||||
|
||||
define sorting = 0, index = 0, elements = 0
|
||||
define timestamp = 0, sorttime = 0
|
||||
define temp1 = 0, temp2 = 0
|
||||
|
||||
cls
|
||||
|
||||
print "Bubble sort benchmark test"
|
||||
|
||||
do
|
||||
|
||||
print "How many elements to generate and sort (max " \
|
||||
print size \
|
||||
print ")? " \
|
||||
|
||||
input elements
|
||||
|
||||
loop elements > size
|
||||
|
||||
gosub fill
|
||||
gosub sort
|
||||
|
||||
print "done!"
|
||||
print "sort time: " \
|
||||
print sorttime
|
||||
print "Press any key to view sorted data..."
|
||||
|
||||
pause
|
||||
|
||||
gosub output
|
||||
|
||||
pause
|
||||
end
|
||||
|
||||
sub fill
|
||||
|
||||
print "filling..."
|
||||
|
||||
0 index
|
||||
|
||||
do
|
||||
|
||||
gosub generaterand
|
||||
|
||||
let @list[index] = rand
|
||||
|
||||
+1 index
|
||||
|
||||
loop index < elements
|
||||
|
||||
return
|
||||
|
||||
sub sort
|
||||
|
||||
print "sorting..."
|
||||
|
||||
gosub systemtime
|
||||
let timestamp = loworder
|
||||
|
||||
do
|
||||
|
||||
0 sorting
|
||||
|
||||
0 index
|
||||
|
||||
do
|
||||
|
||||
let temp1 = index + 1
|
||||
|
||||
if @list[index] > @list[temp1] then
|
||||
|
||||
let temp2 = @list[index]
|
||||
|
||||
let @list[index] = @list[temp1]
|
||||
let @list[temp1] = temp2
|
||||
|
||||
let sorting = 1
|
||||
|
||||
endif
|
||||
|
||||
+1 index
|
||||
|
||||
loop index < elements - 1
|
||||
|
||||
loop sorting = 1
|
||||
|
||||
gosub systemtime
|
||||
let sorttime = ( loworder - timestamp ) / 18
|
||||
|
||||
return
|
||||
|
||||
sub output
|
||||
|
||||
print "printing..."
|
||||
|
||||
0 index
|
||||
|
||||
do
|
||||
|
||||
print @list[index]
|
||||
|
||||
+1 index
|
||||
|
||||
loop index < elements
|
||||
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue