8-Bit Software Online Conversion
:0.B.BUBCOMP - Listing
10IF PAGE<>&1200 THEN PAGE=&1200:CHAI
N"B.BUBCOMP"
20MODE7:@%=&00000405:`%=1000:PRINT'"
How many numbers are to be sorted"'" bet
ween 2 and 10 ":REPEATINPUT£%:UNTIL£%>1A
ND£%<11:PRINT" Array size 2^";£%;" = ";2
^£%:DIMA%(4,£%,4),B%(2^£%):FORa%=1TO4:FO
Rb%=1TO£%:A%(a%,b%,1)=99999999:NEXT:NEXT
30PRINT'" How many different groups o
f data"'" are to be sorted between"'" 1
and 10":REPEATINPUTc%:UNTILc%>0ANDc%<11:
MODE0:VDU23;8202;0;0;0;:PRINTTAB(0,1);"
Current sort type :":PRINTTAB(0,2);" Cur
rent sort size :":PRINTTAB(15,4);"Array
size":PRINTTAB(0,6);"Sort type":FORa%=1T
O4:PRINTTAB(8,a%*4+4);"min"
40PRINTTAB(8,a%*4+5);"av.":PRINTTAB(8
,a%*4+6);"max":NEXT:PRINTTAB(0,9);"Shrin
k":PRINTTAB(0,13);"Twobub":PRINTTAB(0,17
);"Twobubs":PRINTTAB(0,21);"Comb":FORd%=
1TOc%:FORb%=2TO£%:PRINTTAB(b%*7,6);2^b%:
e%=2^b%:PRINTTAB(21,2);" ":PRINTTAB(2
1,2);e%:f%=1:PRINTTAB(21,1);"Shrink ":
PROCA:f%=2:PRINTTAB(21,1);"Twobub ":PR
OCB:f%=3:PRINTTAB(21,1);"Twobubs "
50PROCC:f%=4:PRINTTAB(21,1);"Combsort
":PROCD:NEXT:NEXT:PRINTCHR$(0,20);"Fini
shed.":END
60DEFPROCE:B=RND(-d%):FORa%=0TOe%:B%(
a%)=RND(`%):NEXT:g%=TIME:ENDPROC
70DEFPROCF:g%=TIME-g%:IFg%<A%(f%,b%,1
)A%(f%,b%,1)=g%
80PRINTTAB(b%*7,f%*4+4);A%(f%,b%,1)/1
00:IFg%>A%(f%,b%,3)A%(f%,b%,3)=g%
90PRINTTAB(b%*7,f%*4+6);A%(f%,b%,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