BCX Console Demonstration Program s107.bas |
DIM I DIM Inner DIM Outer DIM Number DIM A$[101] PRINT "UnSorted ..." PRINT FOR I = 1 TO 100 A$[I] = STR$(RND * 100) PRINT I, " ", A$[I] NEXT PRINT PRINT "Sorting ..." Number = 100 GOSUB Sort FOR I = 1 TO 100 PRINT I, " ", A$[I] NEXT END Sort: FOR Outer = 1 TO Number - 1 FOR Inner = Outer + 1 TO Number IF A$[Inner] < A$[Outer] THEN SWAP A$[Inner], A$[Outer] NEXT NEXT RETURN
Result:
UnSorted ... 1 30.7502001523972 2 12.5836446881294 3 0.361891742795706 4 70.9096252918243 5 55.6984186172485 6 68.9511060714722 7 41.8136894702911 8 27.5522798299789 9 93.2966232299805 10 19.2188709974289 11 34.773463010788 12 92.3383831977844 13 82.8985691070557 14 51.7249703407288 15 97.735720872879 16 84.5632791519165 17 83.0920517444611 18 5.17919883131981 19 33.6604118347168 20 86.3768041133881 21 51.9260406494141 22 36.2760782241821 23 44.3548381328583 24 86.4492893218994 25 6.59729391336441 26 18.6986938118935 27 92.3373579978943 28 69.5577085018158 29 80.4263651371002 30 23.853874206543 31 38.2094949483871 32 72.280365228653 33 73.0410873889923 34 28.2180398702621 35 0.180456601083279 36 94.0303683280945 37 55.4339647293091 38 50.0187695026398 39 33.1548392772675 40 56.5605640411377 41 53.5438179969788 42 63.1506681442261 43 48.9100962877274 44 96.8801736831665 45 66.2645876407623 46 58.9247703552246 47 68.6829507350922 48 73.3335971832275 49 48.7325429916382 50 89.9968862533569 51 65.4178857803345 52 7.67563506960869 53 61.9831204414368 54 95.3275978565216 55 20.8984985947609 56 72.8222012519836 57 82.1355998516083 58 60.8372390270233 59 68.5757398605347 60 21.523129940033 61 10.3602282702923 62 36.8458598852158 63 44.3922579288483 64 74.4657933712006 65 25.3382086753845 66 12.2862108051777 67 32.2555750608444 68 86.0999405384064 69 64.4238948822021 70 98.7885177135468 71 99.0026116371155 72 17.7112266421318 73 52.4559438228607 74 32.6132774353027 75 93.4562742710114 76 72.6866483688354 77 15.596117079258 78 85.9868168830872 79 41.3688063621521 80 78.5479009151459 81 91.6662275791168 82 87.7400815486908 83 32.3376476764679 84 97.8541135787964 85 64.3953919410706 86 34.5473438501358 87 12.9683881998062 88 36.2465679645538 89 46.0952758789063 90 0.598820485174656 91 76.7659246921539 92 58.4100961685181 93 76.5057742595673 94 93.2432949542999 95 9.68718975782394 96 4.46416735649109 97 76.9590198993683 98 17.8909242153168 99 19.0979406237602 100 8.38735997676849 Sorting ... 1 0.18045660108327 2 0.36189174279570 3 0.59882048517465 4 10.3602282702923 5 12.286210805177 6 12.583644688129 7 12.968388199806 8 15.596117079258 9 17.7112266421317 10 17.8909242153168 11 18.6986938118932 12 19.0979406237602 13 19.2188709974288 14 20.8984985947604 15 21.523129940033 16 23.8538742065435 17 25.3382086753849 18 27.5522798299785 19 28.2180398702629 20 30.7502001523971 21 32.2555750608449 22 32.337647676467 23 32.6132774353029 24 33.1548392772677 25 33.6604118347164 26 34.5473438501355 27 34.7734630107888 28 36.2465679645538 29 36.2760782241822 30 36.8458598852158 31 38.2094949483878 32 4.46416735649109 33 41.3688063621521 34 41.8136894702911 35 44.3548381328581 36 44.3922579288481 37 46.0952758789063 38 48.7325429916383 39 48.9100962877272 40 5.17919883131984 41 50.0187695026393 42 51.7249703407288 43 51.9260406494141 44 52.4559438228607 45 53.5438179969788 46 55.4339647293098 47 55.6984186172481 48 56.5605640411377 49 58.4100961685181 50 58.9247703552246 51 6.59729391336441 52 60.8372390270233 53 61.9831204414368 54 63.1506681442261 55 64.3953919410706 56 64.4238948822021 57 65.4178857803345 58 66.2645876407623 59 68.5757398605347 60 68.6829507350922 61 68.9511060714725 62 69.5577085018151 63 7.67563506960869 64 70.9096252918248 65 72.2803652286532 66 72.6866483688354 67 72.8222012519836 68 73.0410873889923 69 73.3335971832275 70 74.4657933712006 71 76.5057742595673 72 76.7659246921539 73 76.9590198993683 74 78.5479009151459 75 8.38735997676849 76 80.4263651371002 77 82.1355998516083 78 82.8985691070553 79 83.0920517444617 80 84.5632791519161 81 85.9868168830872 82 86.0999405384064 83 86.3768041133881 84 86.4492893218994 85 87.7400815486908 86 89.9968862533569 87 9.68718975782394 88 91.6662275791168 89 92.3373579978943 90 92.3383831977845 91 93.2432949542999 92 93.2966232299804 93 93.4562742710114 94 94.0303683280945 95 95.3275978565216 96 96.8801736831665 97 97.7357208728795 98 97.85411357879646 99 98.78851771354689 100 99.00261163711556