Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
(Sorting algorithms/Bubble sort in True BASIC) |
Basicgames (talk | contribs) |
||
Line 1,301: | Line 1,301: | ||
dim list[size] |
dim list[size] |
||
gosub fill |
|||
let index = 0 |
|||
gosub sort |
|||
gosub show |
|||
do |
|||
end |
|||
⚫ | |||
sub fill |
|||
⚫ | |||
for index = 0 to size - 1 |
|||
⚫ | |||
do |
|||
print index |
|||
⚫ | |||
⚫ | |||
return |
|||
⚫ | |||
sub sort |
|||
do |
do |
||
let |
let sort = 0 |
||
⚫ | |||
⚫ | |||
if list[index] > list[temp1] then |
if list[index] > list[temp1] then |
||
let temp2 = list[index] |
let temp2 = list[index] |
||
let list[index] = list[temp1] |
let list[index] = list[temp1] |
||
let list[temp1] = temp2 |
let list[temp1] = temp2 |
||
let sort = 1 |
let sort = 1 |
||
endif |
endif |
||
next index |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
return |
|||
loop sort = 1 |
|||
sub show |
|||
let index = 0 |
|||
for index = 0 to size - 1 |
|||
do |
|||
print index ," : ", list[index] |
|||
next index |
|||
return</syntaxhighlight> |
|||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |