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.
 
 
 
 
 
 

40 lines
914 B

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