Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,32 @@
|
|||
100 rem Sorting algorithms/Bubble sort
|
||||
110 LET n = 10
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue