Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,42 @@
|
|||
dim array(15)
|
||||
a = 0
|
||||
b = arraysize(array(),1)
|
||||
|
||||
print "unsort: ";
|
||||
for i = a to b
|
||||
array(i) = int(ran(98))+1
|
||||
print array(i), " ";
|
||||
next i
|
||||
print "\n sort: ";
|
||||
|
||||
gnomeSort(array())
|
||||
|
||||
for i = a to b
|
||||
print array(i), " ";
|
||||
next i
|
||||
print "\n"
|
||||
end
|
||||
|
||||
sub gnomeSort(array())
|
||||
local ub, ul, i, j, temp
|
||||
|
||||
lb = 0 : ub = arraysize(array(),1)
|
||||
i = lb +1 : j = lb +2
|
||||
|
||||
while i <= ub
|
||||
// replace "<=" with ">=" for downwards sort
|
||||
if array(i -1) <= array(i) then
|
||||
i = j
|
||||
j = j + 1
|
||||
else
|
||||
temp = array(i -1)
|
||||
array(i -1) = array(i)
|
||||
array(i) = temp
|
||||
i = i - 1
|
||||
if i = lb then
|
||||
i = j
|
||||
j = j + 1
|
||||
fi
|
||||
fi
|
||||
wend
|
||||
end sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue