Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
45
Task/Permutations/Microsoft-Small-Basic/permutations.basic
Normal file
45
Task/Permutations/Microsoft-Small-Basic/permutations.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
'Permutations - sb
|
||||
n=4
|
||||
printem = "True"
|
||||
For i = 1 To n
|
||||
p[i] = i
|
||||
EndFor
|
||||
count = 0
|
||||
Last = "False"
|
||||
While Last = "False"
|
||||
If printem Then
|
||||
For t = 1 To n
|
||||
TextWindow.Write(p[t])
|
||||
EndFor
|
||||
TextWindow.WriteLine("")
|
||||
EndIf
|
||||
count = count + 1
|
||||
Last = "True"
|
||||
i = n - 1
|
||||
While i > 0
|
||||
If p[i] < p[i + 1] Then
|
||||
Last = "False"
|
||||
Goto exitwhile
|
||||
EndIf
|
||||
i = i - 1
|
||||
EndWhile
|
||||
exitwhile:
|
||||
j = i + 1
|
||||
k = n
|
||||
While j < k
|
||||
t = p[j]
|
||||
p[j] = p[k]
|
||||
p[k] = t
|
||||
j = j + 1
|
||||
k = k - 1
|
||||
EndWhile
|
||||
j = n
|
||||
While p[j] > p[i]
|
||||
j = j - 1
|
||||
EndWhile
|
||||
j = j + 1
|
||||
t = p[i]
|
||||
p[i] = p[j]
|
||||
p[j] = t
|
||||
EndWhile
|
||||
TextWindow.WriteLine("Number of permutations: "+count)
|
||||
Loading…
Add table
Add a link
Reference in a new issue