Bubblesort (script): Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Script |
|||
[[Category:Scripts]] |
|||
|cat=information |
|||
|fe= |
|||
|auth=[[User:Mozuzaeram|Mozuzaeram]] |
|||
}} |
|||
script name suggestion: bubblesort |
script name suggestion: bubblesort |
||
Line 102: | Line 107: | ||
deletevariable % |
deletevariable % |
||
deletevariable arraylen |
deletevariable arraylen |
||
deletevariable i |
deletevariable i</pre> |
||
deletevariable j |
Latest revision as of 12:42, 24 March 2011
Bubblesort (script) | |
---|---|
Category | information |
Front-end | Unknown |
Author | Mozuzaeram |
script name suggestion: bubblesort
counter set 0 setvariable % % setvariable presort { paramloop: if_1 goto saveparam goto sort saveparam: setvariable a%c% %1 counter add 1 setvariable presort %presort% %1 shift goto paramloop sort: setvariable presort %presort% } counter subtract 1 setvariable arraylen %c setvariable i %arraylen looptest_i: match end_i - match loop_i valid flag put set %i matchwait loop_i: setvariable j %arraylen looptest_j: match end_j - match loop_j valid flag put set %j matchwait loop_j: setvariable ai %%a%i setvariable aj %%a%j counter set %ai counter subtract %aj match j_gt_i - match j_eq_i 0 match j_lt_i valid flag put set %c matchwait j_gt_i: echo ***SWAP %ai and %aj setvariable temp %ai setvariable a%i% %aj setvariable a%j% %temp deletevariable temp j_eq_i: j_lt_i: deletevariable ai deletevariable aj counter set %j counter subtract 1 setvariable j %c goto looptest_j end_j: deletevariable j counter set %i counter subtract 1 setvariable i %c goto looptest_i end_i: deletevariable i setvariable i %arraylen setvariable result } looptest_i2: match end_i2 -1 match loop_i2 valid flag put set %i matchwait loop_i2: setvariable iptr %%a%i% setvariable result %iptr% %result% deletevariable a%i% deletevariable iptr counter set %i counter subtract 1 setvariable i %c goto looptest_i2 end_i2: setvariable result { %result% echo *** %presort ==> %result deletevariable presort deletevariable result deletevariable % deletevariable arraylen deletevariable i