本帖最后由 rolaka 于 2010-8-22 16:34 编辑 $input = InputBox("枚举", "输入元素")
$time = TimerInit()
$array = StringSplit($input, "", 2)
For $i = 1 To (2^UBound($array))-1
$out = ""
For $n = 0 To UBound($array)-1
If BitAND(BitShift($i, $n), 1) == 1 Then
$out &= $array[$n]
EndIf
Next
ConsoleWrite("out: " & $out & @CRLF)
Next
MsgBox(0, "End", TimerDiff($time))
我想得起来的最快方法...与非门的内容还没忘记...
好像比_ArrayCombinations要慢几ms...不知道是不是StringSplit的原因
15位元素
2785ms 其中拼合字符串花了600ms左右...
版本2:
好像是这样的...是节省一半的时间...但实际花的时间...orz$input = InputBox("枚举", "输入元素")
$time = TimerInit()
$array = StringSplit($input, "", 2)
$i = 0
For $i = 1 To ((2 ^ UBound($array)) / 2) - 1
$out = ""
$out2 = ""
For $n = 0 To UBound($array) - 1
If BitAND(BitShift($i, $n), 1) == 1 Then
$out &= $array[$n]
Else
$out2 &= $array[$n]
EndIf
Next
ConsoleWrite("" & $out & @CRLF)
ConsoleWrite("" & $out2 & @CRLF)
Next
$out = ""
For $n = 0 To UBound($array) - 1
$out &= $array[$n]
Next
ConsoleWrite("" & $out & @CRLF)
MsgBox(0, "End", TimerDiff($time))
15个元素
平均1600ms朝上...
好像是str和int的问题...orz |