RosettaCodeData/Task/Permutations/BASIC256/permutations.basic

44 lines
629 B
Plaintext

arraybase 1
n = 4 : cont = 0
dim a(n)
dim c(n)
for j = 1 to n
a[j] = j
next j
do
for i = 1 to n
print a[i];
next
print " ";
i = n
cont += 1
if cont = 12 then
print
cont = 0
else
print " ";
end if
do
i -= 1
until (i = 0) or (a[i] < a[i+1])
j = i + 1
k = n
while j < k
tmp = a[j] : a[j] = a[k] : a[k] = tmp
j += 1
k -= 1
end while
if i > 0 then
j = i + 1
while a[j] < a[i]
j += 1
end while
tmp = a[j] : a[j] = a[i] : a[i] = tmp
end if
until i = 0
end