Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Knuth-shuffle/FutureBasic/knuth-shuffle.basic
Normal file
25
Task/Knuth-shuffle/FutureBasic/knuth-shuffle.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
void local fn KnuthShuffle( mutArr as CFMutableArrayRef )
|
||||
NSUInteger i, j, count
|
||||
|
||||
count = len(mutArr)
|
||||
for i = count-1 to 1 step -1
|
||||
j = rnd(i+1)-1
|
||||
MutableArrayExchangeObjects( mutArr, i, j )
|
||||
next
|
||||
end fn
|
||||
|
||||
randomize
|
||||
|
||||
CFMutableArrayRef mutArr
|
||||
NSUInteger i
|
||||
mutArr = fn MutableArrayWithObjects( @0, @1, @2, @3, @4, @5, @6, @7, @8, @9, NULL )
|
||||
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
|
||||
|
||||
for i = 1 to 100
|
||||
fn KnuthShuffle( mutArr )
|
||||
NSLog( @"%@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
|
||||
next
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue