Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
34
Task/Permutations/Eiffel/permutations.e
Normal file
34
Task/Permutations/Eiffel/permutations.e
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
permute(a: ARRAY[INTEGER]; k: INTEGER)
|
||||
require
|
||||
ar_not_void: a.count>=1
|
||||
k_valid_index: k>0
|
||||
local
|
||||
i,t: INTEGER
|
||||
do
|
||||
if k=a.count then
|
||||
across a as ar loop io.put_string (ar.item.out) end
|
||||
io.put_string ("%N")
|
||||
else
|
||||
from
|
||||
i:= k
|
||||
until
|
||||
i> a.count
|
||||
loop
|
||||
t:= a[k]
|
||||
a[k]:= a[i]
|
||||
a[i]:= t
|
||||
permute(a,k+1)
|
||||
t:= a[k]
|
||||
a[k]:= a[i]
|
||||
a[i]:= t
|
||||
i:= i+1
|
||||
end
|
||||
end
|
||||
make
|
||||
do
|
||||
test:= << 2,5,1>>
|
||||
permute(test, 1)
|
||||
end
|
||||
test: ARRAY[INTEGER]
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue