Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,28 @@
class
STOOGE_SORT
feature
stoogesort (ar: ARRAY[INTEGER]; i,j: INTEGER)
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,20 @@
class
APPLICATION
inherit
ARGUMENTS
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