看哈这个范例对吗
#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=1 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,"拍序后的随即不重复数组")
这个范例 我在AU3 上面写了 可是编译成脚本 提示错无 在帮忙看一哈 For $i=1 to $n-2
For $j=$i+1 to $n-1
这个双重循环的意思具体一点 先谢谢大家了:face (35): #include<Array.au3>
Const $n = 11
Dim $RandomNumArray[$n]
Dim $Num, $i, $j, $Flag, $t
$i = 0
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, "拍序后的随即不重复数组") 错无到是没的但是 出现死循环了
页:
[1]