Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
68
Task/Permutations/Craft-Basic/permutations.basic
Normal file
68
Task/Permutations/Craft-Basic/permutations.basic
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
let n = 3
|
||||
let i = n + 1
|
||||
|
||||
dim a[i]
|
||||
|
||||
for i = 1 to n
|
||||
|
||||
let a[i] = i
|
||||
|
||||
next i
|
||||
|
||||
do
|
||||
|
||||
for i = 1 to n
|
||||
|
||||
print a[i]
|
||||
|
||||
next i
|
||||
|
||||
print
|
||||
|
||||
let i = n
|
||||
|
||||
do
|
||||
|
||||
let i = i - 1
|
||||
let b = i + 1
|
||||
|
||||
loopuntil (i = 0) or (a[i] < a[b])
|
||||
|
||||
let j = i + 1
|
||||
let k = n
|
||||
|
||||
do
|
||||
|
||||
if j < k then
|
||||
|
||||
let t = a[j]
|
||||
let a[j] = a[k]
|
||||
let a[k] = t
|
||||
let j = j + 1
|
||||
let k = k - 1
|
||||
|
||||
endif
|
||||
|
||||
loop j < k
|
||||
|
||||
if i > 0 then
|
||||
|
||||
let j = i + 1
|
||||
|
||||
do
|
||||
|
||||
if a[j] < a[i] then
|
||||
|
||||
let j = j + 1
|
||||
|
||||
endif
|
||||
|
||||
loop a[j] < a[i]
|
||||
|
||||
let t = a[j]
|
||||
let a[j] = a[i]
|
||||
let a[i] = t
|
||||
|
||||
endif
|
||||
|
||||
loopuntil i = 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue