RosettaCodeData/Task/Knuth-shuffle/Liberty-BASIC/knuth-shuffle.basic

23 lines
536 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
'Declared the UpperBound to prevent confusion with lots of 9's floating around....
UpperBound = 9
Dim array(UpperBound)
For i = 0 To UpperBound
array(i) = Int(Rnd(1) * 10)
Print array(i)
Next i
For i = 0 To UpperBound
'set a random value because we will need to use the same value twice
randval = Int(Rnd(1) * (UpperBound - i))
temp1 = array(randval)
temp2 = array((UpperBound - i))
array(randval) = temp2
array((UpperBound - i)) = temp1
Next i
Print
For i = 0 To UpperBound
Print array(i)
Next i