8-Bit Software Online Conversion

:0.B.BUBBLE - Listing

10REM "B.BUBBLE" 20REM BUBBLE SORT 30REM SIMPLEST FORM 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 370REPEAT 380pass%=pass%+1 390flag=FALSE 400FOR loop%=0 TO size%-1 410IF A%(loop%)<A%(loop%+1) THEN swap% =A%(loop%):A%(loop%)=A%(loop%+1):A%(loop %+1)=swap%:flag=TRUE 420NEXT loop% 430PROCshowdata 440UNTIL flag=FALSE 450ENDPROC