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,30 @@
DECLARE SUB InsertionSort (theList() AS INTEGER)
DIM n(10) AS INTEGER, L AS INTEGER, o AS STRING
FOR L = 0 TO 10
n(L) = INT(RND * 32768)
NEXT
InsertionSort n()
FOR L = 1 TO 10
PRINT n(L); ";";
NEXT
SUB InsertionSort (theList() AS INTEGER)
DIM insertionElementIndex AS INTEGER
FOR insertionElementIndex = 1 TO UBOUND(theList)
DIM insertionElement AS INTEGER
insertionElement = theList(insertionElementIndex)
DIM j AS INTEGER
j = insertionElementIndex - 1
DO WHILE (j >= 0)
'necessary for BASICs without short-circuit evaluation
IF (insertionElement < theList(j)) THEN
theList(j + 1) = theList(j)
j = j - 1
ELSE
EXIT DO
END IF
LOOP
theList(j + 1) = insertionElement
NEXT
END SUB