Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
Basicgames (talk | contribs) |
|||
Line 1,402: | Line 1,402: | ||
==={{header|FTCBASIC}}=== |
==={{header|FTCBASIC}}=== |
||
<syntaxhighlight lang="basic"> |
<syntaxhighlight lang="basic">rem bubble sort benchmark example |
||
rem compile with FTCBASIC |
|||
use time.inc |
|||
use random.inc |
use random.inc |
||
define |
define const size = 32000 |
||
⚫ | |||
define sorting = 0, index = 0, elements = 0 |
|||
define timestamp = 0, sorttime = 0 |
define timestamp = 0, sorttime = 0 |
||
define temp1 = 0, temp2 = 0 |
define temp1 = 0, temp2 = 0 |
||
⚫ | |||
cls |
cls |
||
print "Bubble sort benchmark test" |
print "Bubble sort benchmark test" |
||
⚫ | |||
do |
|||
input size |
|||
⚫ | |||
print size \ |
|||
print ")? " \ |
|||
input elements |
|||
loop elements > size |
|||
gosub fill |
gosub fill |
||
Line 1,447: | Line 1,459: | ||
+1 index |
+1 index |
||
loop index < |
loop index < elements |
||
return |
return |
||
Line 1,481: | Line 1,493: | ||
+1 index |
+1 index |
||
loop index < |
loop index < elements - 1 |
||
loop sorting = 1 |
loop sorting = 1 |
||
Line 1,502: | Line 1,514: | ||
+1 index |
+1 index |
||
loop index < |
loop index < elements |
||
return</syntaxhighlight> |
return</syntaxhighlight> |