Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,34 +0,0 @@
|
|||
function flip(sequence s, integer n)
|
||||
object temp
|
||||
for i = 1 to n/2 do
|
||||
temp = s[i]
|
||||
s[i] = s[n-i+1]
|
||||
s[n-i+1] = temp
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
|
||||
function pancake_sort(sequence s)
|
||||
integer m
|
||||
for i = length(s) to 2 by -1 do
|
||||
m = 1
|
||||
for j = 2 to i do
|
||||
if compare(s[j], s[m]) > 0 then
|
||||
m = j
|
||||
end if
|
||||
end for
|
||||
|
||||
if m < i then
|
||||
if m > 1 then
|
||||
s = flip(s,m)
|
||||
end if
|
||||
s = flip(s,i)
|
||||
end if
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
|
||||
constant s = rand(repeat(100,10))
|
||||
|
||||
? s
|
||||
? pancake_sort(s)
|
||||
Loading…
Add table
Add a link
Reference in a new issue