Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Knuth-shuffle/VBScript/knuth-shuffle-1.vb
Normal file
19
Task/Knuth-shuffle/VBScript/knuth-shuffle-1.vb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function shuffle( a )
|
||||
dim i
|
||||
dim r
|
||||
randomize timer
|
||||
for i = lbound( a ) to ubound( a )
|
||||
r = int( rnd * ( ubound( a ) + 1 ) )
|
||||
if r <> i then
|
||||
swap a(i), a(r)
|
||||
end if
|
||||
next
|
||||
shuffle = a
|
||||
end function
|
||||
|
||||
sub swap( byref a, byref b )
|
||||
dim tmp
|
||||
tmp = a
|
||||
a = b
|
||||
b = tmp
|
||||
end sub
|
||||
14
Task/Knuth-shuffle/VBScript/knuth-shuffle-2.vb
Normal file
14
Task/Knuth-shuffle/VBScript/knuth-shuffle-2.vb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
dim a
|
||||
a = array( 1,2,3,4,5,6,7,8,9)
|
||||
wscript.echo "before: ", join( a, ", " )
|
||||
shuffle a
|
||||
wscript.echo "after: ", join( a, ", " )
|
||||
shuffle a
|
||||
wscript.echo "after: ", join( a, ", " )
|
||||
wscript.echo "--"
|
||||
a = array( now(), "cow", 123, true, sin(1), 16.4 )
|
||||
wscript.echo "before: ", join( a, ", " )
|
||||
shuffle a
|
||||
wscript.echo "after: ", join( a, ", " )
|
||||
shuffle a
|
||||
wscript.echo "after: ", join( a, ", " )
|
||||
Loading…
Add table
Add a link
Reference in a new issue