8-Bit Software Online Conversion
:0.B.SHRINK - Listing
10REM "SHRINK"
20REM Bubble Sort
30REM Auto Shrink
40:
50MODE7:VDU23;8202;0;0;0;
60@%=&50506
70ONERRORREPORT:PRINT" at line ";ERL:
END
80pass%=0
90size%=20
100max%=40
110seed%=1
120DIMA%(size%)
130PROCrandomize
140PROCbubble`sort
150PRINTCHR$(11)+" Sorted."
160END
170:
180DEFPROCrandomize
190seed%=RND(-seed%)
200FOR loop%=0 TO size%
210A%(loop%)=RND(max%)
220NEXT loop%
230PROCshowdata
240ENDPROC
250:
260DEFPROCshowdata
270CLS:PRINT" Bubble sort routine."'"
Pass number ";pass%;
280IF pass%=0 THEN PRINT" Initial stat
e." ELSE PRINT
290FOR loop%=0 TO size%
300PRINTA%(loop%)
310NEXT loop%
320PRINT" <SPACE>"
330REPEAT:A=GET:UNTIL A=32
340ENDPROC
350:
360DEFPROCbubble`sort
370low%=size%
380REPEAT
390pass%=pass%+1
400flag=FALSE
410FOR loop%=0 TO low%-1
420IF A%(loop%)<A%(loop%+1) THEN swap%
=A%(loop%):A%(loop%)=A%(loop%+1):A%(loop
%+1)=swap%:flag=TRUE
430NEXT loop%
440low%=low%-1
450PROCshowdata
460UNTIL flag=FALSE
470ENDPROC