Sorting algorithms/Bubble sort: Difference between revisions

Line 1,402:
 
==={{header|FTCBASIC}}===
<syntaxhighlight lang="basic">defineuse sorting = 0, index = 0, size = 10, temp1 = 0, temp2 = 0time.inc
use random.inc
 
define sorting = 0, index = 0, size = 0
dim list[10]
define timestamp = 0, sorttime = 0
define temp1 = 0, temp2 = 0
 
dim list[1032000]
 
cls
 
print "Bubble sort benchmark test"
print "How many elements to generate and sort (max 32000)? " \
 
input size
 
gosub fill
gosub sort
 
print ": done!" \
print "sort time: " \
print sorttime
print "Press any key to view sorted data..."
 
pause
 
gosub output
 
Line 1,414 ⟶ 1,434:
 
sub fill
 
print "filling..."
 
0 index
Line 1,419 ⟶ 1,441:
do
 
gosub generaterand
print "Enter value #" \
print index \
print ": " \
 
inputlet @list[index] = rand
 
+1 index
Line 1,432 ⟶ 1,452:
 
sub sort
 
print "sorting..."
 
gosub systemtime
let timestamp = loworder
 
do
Line 1,459 ⟶ 1,484:
 
loop sorting = 1
 
gosub systemtime
let sorttime = ( loworder - timestamp ) / 18
 
return
 
sub output
 
print "printing..."
 
0 index
Line 1,468 ⟶ 1,498:
do
 
print "#" \
print index \
print ": " \
print @list[index]
 
305

edits