all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,69 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols binary
|
||||
|
||||
import java.util.List
|
||||
|
||||
icounts = [int -
|
||||
1, 3, 6, 2, 7, 13, 20, 12, 21, 11 -
|
||||
, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42 -
|
||||
, 63, 41, 18, 42, 17, 43, 16, 44, 15, 45 -
|
||||
, 14, 46, 79, 113, 78, 114, 77, 39, 78, 38 -
|
||||
]
|
||||
scounts = int[icounts.length]
|
||||
|
||||
System.arraycopy(icounts, 0, scounts, 0, icounts.length)
|
||||
lists = [ -
|
||||
icounts -
|
||||
, countingSort(scounts) -
|
||||
]
|
||||
|
||||
loop ln = 0 to lists.length - 1
|
||||
cl = lists[ln]
|
||||
rep = Rexx('')
|
||||
loop ct = 0 to cl.length - 1
|
||||
rep = rep cl[ct]
|
||||
end ct
|
||||
say '['rep.strip.changestr(' ', ',')']'
|
||||
end ln
|
||||
|
||||
return
|
||||
|
||||
method getMin(array = int[]) public constant binary returns int
|
||||
|
||||
amin = Integer.MAX_VALUE
|
||||
loop x_ = 0 to array.length - 1
|
||||
if array[x_] < amin then
|
||||
amin = array[x_]
|
||||
end x_
|
||||
|
||||
return amin
|
||||
|
||||
method getMax(array = int[]) public constant binary returns int
|
||||
|
||||
amax = Integer.MIN_VALUE
|
||||
loop x_ = 0 to array.length - 1
|
||||
if array[x_] > amax then
|
||||
amax = array[x_]
|
||||
end x_
|
||||
|
||||
return amax
|
||||
|
||||
method countingSort(array = int[], amin = getMin(array), amax = getMax(array)) public constant binary returns int[]
|
||||
|
||||
count = int[amax - amin + 1]
|
||||
loop nr = 0 to array.length - 1
|
||||
numbr = array[nr]
|
||||
count[numbr - amin] = count[numbr - amin] + 1
|
||||
end nr
|
||||
|
||||
z_ = 0
|
||||
|
||||
loop i_ = amin to amax
|
||||
loop label count while count[i_ - amin] > 0
|
||||
array[z_] = i_
|
||||
z_ = z_ + 1
|
||||
count[i_ - amin] = count[i_ - amin] - 1
|
||||
end count
|
||||
end i_
|
||||
|
||||
return array
|
||||
Loading…
Add table
Add a link
Reference in a new issue