8-Bit Software Online Conversion

:0.B.TWOBUB - Listing

10REM "TWOBUB" 20REM Bubble Sort 30REM Two Way 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:UNTIL GET=32 340ENDPROC 350: 360DEFPROCbubble`sort 370REPEAT 380flag=FALSE 390pass%=pass%+1 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 440pass%=pass%+1 450FOR loop%=size% TO 1 STEP -1 460IF A%(loop%)>A%(loop%-1) THEN swap% =A%(loop%):A%(loop%)=A%(loop%-1):A%(loop %-1)=swap%:flag=TRUE 470NEXT loop% 480PROCshowdata 490UNTIL flag=FALSE 500ENDPROC