all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,32 @@
DIM test(9)
test() = 4, 65, 2, -31, 0, 99, 2, 83, 782, 1
PROCpancakesort(test())
FOR i% = 0 TO 9
PRINT test(i%) ;
NEXT
PRINT
END
DEF PROCpancakesort(a())
LOCAL i%, j%, m%
FOR i% = DIM(a(),1)+1 TO 2 STEP -1
m% = 0
FOR j% = 1 TO i%-1
IF a(j%) > a(m%) m% = j%
NEXT
m% += 1
IF m% < i% THEN
IF m% > 1 PROCflip(a(), m%)
PROCflip(a(), i%)
ENDIF
NEXT
ENDPROC
DEF PROCflip(a(), n%)
IF n% < 2 ENDPROC
LOCAL i%
n% -= 1
FOR i% = 0 TO n% DIV 2
SWAP a(i%), a(n%-i%)
NEXT
ENDPROC