Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Knuth-shuffle/AutoIt/knuth-shuffle.autoit
Normal file
25
Task/Knuth-shuffle/AutoIt/knuth-shuffle.autoit
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Dim $a[10]
|
||||
ConsoleWrite('array before permutation:' & @CRLF)
|
||||
For $i = 0 To 9
|
||||
$a[$i] = Random(20,100,1)
|
||||
ConsoleWrite($a[$i] & ' ')
|
||||
Next
|
||||
ConsoleWrite(@CRLF)
|
||||
|
||||
_Permute($a)
|
||||
ConsoleWrite('array after permutation:' & @CRLF)
|
||||
For $i = 0 To UBound($a) -1
|
||||
ConsoleWrite($a[$i] & ' ')
|
||||
Next
|
||||
ConsoleWrite(@CRLF)
|
||||
|
||||
|
||||
Func _Permute(ByRef $array)
|
||||
Local $random, $tmp
|
||||
For $i = UBound($array) -1 To 0 Step -1
|
||||
$random = Random(0,$i,1)
|
||||
$tmp = $array[$random]
|
||||
$array[$random] = $array[$i]
|
||||
$array[$i] = $tmp
|
||||
Next
|
||||
EndFunc
|
||||
Loading…
Add table
Add a link
Reference in a new issue