tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
26
Task/Permutations/PowerBASIC/permutations.powerbasic
Normal file
26
Task/Permutations/PowerBASIC/permutations.powerbasic
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
defint a-z
|
||||
option base 1
|
||||
input "n=",n
|
||||
dim a(n)
|
||||
for i=1 to n: a(i)=i: next
|
||||
do
|
||||
for i=1 to n: print a(i);: next: print
|
||||
i=n
|
||||
do
|
||||
decr i
|
||||
loop until i=0 or a(i)<a(i+1)
|
||||
j=i+1
|
||||
k=n
|
||||
while j<k
|
||||
swap a(j),a(k)
|
||||
incr j
|
||||
decr k
|
||||
wend
|
||||
if i>0 then
|
||||
j=i+1
|
||||
while a(j)<a(i)
|
||||
incr j
|
||||
wend
|
||||
swap a(i),a(j)
|
||||
end if
|
||||
loop until i=0
|
||||
Loading…
Add table
Add a link
Reference in a new issue