home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disc 35 / Commodore_Disc_35_19xx_-_de.d64 / quick-sort.txt (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  757b  |  25 lines

  1. 100 dim e$(10),a$(10),l%(16),r%(16)
  2. 110 data"ram","monitor","floppy","disc","rom","computer","tasten","joystick","drucker","basic"
  3. 120 fori=1to10:reade$(i):next
  4. 130 d=10
  5. 140 fori=1tod:a$(i)=e$(i):next
  6. 150 at=ti:gosub 210:at=ti-at
  7. 160 fori=1tod:printe$(i),a$(i):next
  8. 170 print:printat:end
  9. 180 rem ------------------------------
  10. 190 rem   quicksort text
  11. 200 rem ------------------------------
  12. 210 l%(1)=1:r%(1)=d:eb=2
  13. 220 eb=eb-1:ifeb=0thenreturn
  14. 230 if l%(eb)>=r%(eb) then 220
  15. 240 l=l%(eb):r=r%(eb):vw$=a$(int((l+r)/2))
  16. 250 ifa$(l)<vw$ then l=l+1:goto250
  17. 260 ifa$(r)>vw$ then r=r-1:goto260
  18. 270 ifl>r then 300
  19. 280 a$=a$(l):a$(l)=a$(r):a$(r)=a$
  20. 290 l=l+1:r=r-1:ifl<=r then 250
  21. 300 eb=eb+1
  22. 310 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto230
  23. 320 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto230
  24. 330 rem ------------------------------
  25.