ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
866 B

  1. 10 REM BUBBLESORT FOR STRINGS
  2. 80 CALL SHELL("cls")
  3. 90 DIM A$(8)
  4. : REM ARRAY WITH 8 STRINGS
  5. 100 REM ASK FOR 8 STRINGS
  6. 105 PRINT "You will be asked for 8 strings"
  7. 110 FOR I = 1 TO 8
  8. 120 PRINT "Type string ";I;" : ";
  9. 130 INPUT A$ (I)
  10. 140 NEXT I
  11. 150 REM PASS THROUGH 8 STRINGS, TESTING BY PAIRS
  12. 160 F = 0
  13. : REM RESET THE ORDER INDICATOR
  14. 170 FOR I = 1 TO 7
  15. 180 IF A$(I) <= A$(I+1) THEN
  16. : GOTO 240
  17. : END IF
  18. 190 REM SWAP A$(I) AND A$(I+1)
  19. 200 T$ = A$(I)
  20. 210 A$(I) = A$(I+1)
  21. 220 A$(I+1) = T$
  22. 230 F = 1
  23. : REM ORDER WAS NOT PERFECT
  24. 240 NEXT I
  25. 250 REM F = 0 MEANS ORDER IS PERFECT
  26. 260 IF F = 1 THEN
  27. : GOTO 160
  28. : END IF
  29. : REM TRY AGAIN
  30. 270 PRINT
  31. : REM PRINT EMPTY LINE
  32. 280 REM PRINT ORDERED STRINGS
  33. 290 FOR I = 1 TO 8
  34. 300 PRINT A$ (I)
  35. 310 NEXT I
  36. 320 print