all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
function cocktailSort( a )
|
||||
dim swapped
|
||||
dim i
|
||||
do
|
||||
swapped = false
|
||||
for i = 0 to ubound( a ) - 1
|
||||
if a(i) > a(i+1) then
|
||||
swap a(i), a(i+1)
|
||||
swapped = true
|
||||
end if
|
||||
next
|
||||
if not swapped then exit do
|
||||
swapped = false
|
||||
for i = ubound( a ) - 1 to 0 step -1
|
||||
if a(i) > a( i+1) then
|
||||
swap a(i), a(i+1)
|
||||
swapped = true
|
||||
end if
|
||||
next
|
||||
if not swapped then exit do
|
||||
loop
|
||||
cocktailSort = a
|
||||
end function
|
||||
|
||||
sub swap( byref a, byref b)
|
||||
dim tmp
|
||||
tmp = a
|
||||
a = b
|
||||
b = tmp
|
||||
end sub
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
dim a
|
||||
a = array( "portcullis", "redoubt", "palissade", "turret", "collins", "the parapet", "the quarterdeck")
|
||||
wscript.echo join( a, ", ")
|
||||
|
||||
dim b
|
||||
b = cocktailSort( a )
|
||||
wscript.echo join( b, ", ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue