Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
|||
function findMax( a )
|
||||
dim num
|
||||
dim max
|
||||
max = 0
|
||||
for each num in a
|
||||
if num > max then max = num
|
||||
next
|
||||
findMax = max
|
||||
end function
|
||||
|
||||
function findMin( a )
|
||||
dim num
|
||||
dim min
|
||||
min = 0
|
||||
for each num in a
|
||||
if num < min then min = num
|
||||
next
|
||||
findMin = min
|
||||
end function
|
||||
|
||||
'the function returns the sorted array, but the fact is that VBScript passes the array by reference anyway
|
||||
function countingSort( a )
|
||||
dim count()
|
||||
dim min, max
|
||||
min = findMin(a)
|
||||
max = findMax(a)
|
||||
redim count( max - min + 1 )
|
||||
dim i
|
||||
dim z
|
||||
for i = 0 to ubound( a )
|
||||
count( a(i) - min ) = count( a( i ) - min ) + 1
|
||||
next
|
||||
z = 0
|
||||
for i = min to max
|
||||
while count( i - min) > 0
|
||||
a(z) = i
|
||||
z = z + 1
|
||||
count( i - min ) = count( i - min ) - 1
|
||||
wend
|
||||
next
|
||||
countingSort = a
|
||||
end function
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
dim a
|
||||
a = array(300, 1, -2, 3, -4, 5, -6, 7, -8, 100, 11 )
|
||||
wscript.echo join( a, ", " )
|
||||
countingSort a
|
||||
wscript.echo join( a, ", " )
|
||||
Loading…
Add table
Add a link
Reference in a new issue