Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,29 +1,29 @@
|
|||
class
|
||||
STOOGE_SORT
|
||||
STOOGE_SORT
|
||||
feature
|
||||
stoogesort (ar: ARRAY[INTEGER]; i,j: INTEGER)
|
||||
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
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
class
|
||||
APPLICATION
|
||||
APPLICATION
|
||||
|
||||
create
|
||||
make
|
||||
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
|
||||
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]
|
||||
test: ARRAY [INTEGER]
|
||||
|
||||
stoogesort: STOOGE_SORT
|
||||
stoogesort: STOOGE_SORT
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue