Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Knuth-shuffle/Ring/knuth-shuffle.ring
Normal file
28
Task/Knuth-shuffle/Ring/knuth-shuffle.ring
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Project : Knuth shuffle
|
||||
|
||||
items = list(52)
|
||||
for n = 1 to len(items)
|
||||
items[n] = n
|
||||
next
|
||||
knuth(items)
|
||||
showarray(items)
|
||||
|
||||
func knuth(items)
|
||||
for i = len(items) to 1 step -1
|
||||
j = random(i-1) + 1
|
||||
if i != j
|
||||
temp = items[i]
|
||||
items[i] = items[j]
|
||||
items[j] = temp
|
||||
ok
|
||||
next
|
||||
|
||||
func showarray(vect)
|
||||
see "["
|
||||
svect = ""
|
||||
for n = 1 to len(vect)
|
||||
svect = svect + vect[n] + " "
|
||||
next
|
||||
svect = left(svect, len(svect) - 1)
|
||||
see svect
|
||||
see "]" + nl
|
||||
Loading…
Add table
Add a link
Reference in a new issue