Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
flip := proc(arr, i)
|
||||
local start, temp, icopy;
|
||||
temp, start, icopy := 0,1,i:
|
||||
while (start < icopy) do
|
||||
arr[start], arr[icopy] := arr[icopy], arr[start]:
|
||||
start:=start+1:
|
||||
icopy:=icopy-1:
|
||||
end do:
|
||||
end proc:
|
||||
findMax := proc(arr, i)
|
||||
local Max, j:
|
||||
Max := 1:
|
||||
for j from 1 to i do
|
||||
if arr[j] > arr[Max] then Max := j: end if:
|
||||
end do:
|
||||
return Max:
|
||||
end proc:
|
||||
pancakesort := proc(arr)
|
||||
local len,i,Max;
|
||||
len := numelems(arr):
|
||||
for i from len to 2 by -1 do
|
||||
print(arr):
|
||||
Max := findMax(arr, i):
|
||||
if (not Max = i) then
|
||||
flip(arr, Max):
|
||||
flip(arr, i):
|
||||
end if:
|
||||
end do:
|
||||
print(arr);
|
||||
end proc:
|
||||
Loading…
Add table
Add a link
Reference in a new issue