Sorting algorithms/Bubble sort: Difference between revisions

Sorting algorithms/Bubble sort in Quite BASIC
(Added Chipmunk Basic)
(Sorting algorithms/Bubble sort in Quite BASIC)
Line 1,902:
NEXT I
PRINT
END</syntaxhighlight>
END
</syntaxhighlight>
{{out}} (2 samples)
<pre>Before: 91 97 3 62 17 48 89 7 2 66
<pre>
BeforeAfter: 91 97 2 3 62 7 17 48 8962 66 789 91 2 6697</pre>
After<pre>Before: 22 60 245 44 354 93 784 1727 4821 62 66 89 91 9764
After: 21 22 27 44 45 54 60 64 84 93</pre>
</pre>
 
<pre>
==={{header|Quite BASIC}}===
Before: 22 60 45 44 54 93 84 27 21 64
<syntaxhighlight lang="qbasic">100 rem Sorting algorithms/Bubble sort
After: 21 22 27 44 45 54 60 64 84 93
110 LET n = 10
</pre>
120 array a
130 GOSUB 310
140 PRINT "unsort ";
150 GOSUB 360
160 rem Sort the array
170 GOSUB 210
180 PRINT " sort ";
190 GOSUB 360
200 END
210 rem Bubble sort the list A of length N
220 FOR i = 1 TO n-1
230 FOR j = 1 TO n-i
240 IF a[j] <= a[j+1] THEN GOTO 280
250 LET x = a[j]
260 LET a[j] = a[j+1]
270 LET a[j+1] = x
280 NEXT j
290 NEXT i
300 RETURN
310 rem Create a RANDOM list of N integers
320 FOR i = 1 TO n
330 LET a[i] = FLOOR(RAND(100))
340 NEXT i
350 RETURN
360 rem Print the list a
370 FOR i = 1 TO n
380 PRINT a[i];" ";
390 NEXT i
400 PRINT
410 RETURN</syntaxhighlight>
{{out}}
<pre>unsort 19 78 39 54 63 68 66 52 94 2
sort 2 19 39 52 54 63 66 68 78 94 </pre>
 
==={{header|RapidQ}}===
Line 1,950 ⟶ 1,982:
NEXT I
PRINT
END</syntaxhighlight>
END
</syntaxhighlight>
{{out}} (2 samples)
<pre>Before: 2282 6034 4557 44 5448 9371 8419 2733 2173 6462
<pre>
BeforeAfter: 82 3419 5733 34 44 48 7157 1962 3371 73 6282</pre>
After<pre>Before: 194 3315 3496 4493 4827 5724 62 719 7380 8210 21
After: 4 9 10 15 21 24 27 80 93 96</pre>
</pre>
<pre>
Before: 4 15 96 93 27 24 9 80 10 21
After: 4 9 10 15 21 24 27 80 93 96
</pre>
 
==={{header|REALbasic}}===
2,122

edits