Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,29 @@
class
STOOGE_SORT
feature
stoogesort (ar: ARRAY[INTEGER]; i,j: INTEGER)
-- Sorted array in ascending order.
require
ar_not_empty: ar.count >= 0
i_in_range: i>=1
j_in_range: j <= ar.count
boundary_set: i<=j
local
t: REAL_64
third: INTEGER
swap: INTEGER
do
if ar[j]< ar[i] then
swap:= ar[i]
ar[i]:=ar[j]
ar[j]:= swap
end
if j-i >1 then
t:= (j-i+1)/3
third:= t.floor
stoogesort(ar, i, j-third)
stoogesort(ar, i+third, j)
stoogesort(ar, i, j-third)
end
end
end

View file

@ -0,0 +1,32 @@
class
APPLICATION
create
make
feature
make
do
test := <<2, 5, 66, -2, 0, 7>>
io.put_string ("%Nunsorted:%N")
across
test as ar
loop
io.put_string (ar.item.out + "%T")
end
create stoogesort
stoogesort.stoogesort (test, 1, test.count)
io.put_string ("%Nsorted:%N")
across
test as ar
loop
io.put_string (ar.item.out + "%T")
end
end
test: ARRAY [INTEGER]
stoogesort: STOOGE_SORT
end