|
#include<Array.au3>
Const $n = 11
Dim $RandomNumArray[$n]
Dim $Num, $i, $j, $Flag, $t
$i = 1
While $i < $n
$Num = Random(1, 10, 1)
$Flag = 0
$j = 1
While $j < $i
If $Num = $RandomNumArray[$j] Then
$Flag = 1
ExitLoop
Else
$j = $j + 1
EndIf
WEnd
If $Flag = 0 Then
$RandomNumArray[$i] = $Num
$i = $i + 1
EndIf
WEnd
_ArrayDisplay($RandomNumArray, "随即不重复数组")
For $i = 0 To $n - 2
For $j = $i + 1 To $n - 1
If $RandomNumArray[$j] < $RandomNumArray[$i] Then
$t = $RandomNumArray[$i]
$RandomNumArray[$i] = $RandomNumArray[$j]
$RandomNumArray[$j] = $t
EndIf
Next
Next
_ArrayDisplay($RandomNumArray, "拍序后的随即不重复数组") |
|