8-Bit Software Online Conversion

:0.B.COMBSRT - Listing

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