[已解决]数组中有中文就不能搜索?
本帖最后由 cxm23 于 2010-12-19 10:11 编辑#include <array.au3>
Local $avArray
$avArray = "张三"
$avArray = "李四"
$avArray = "王五"
$avArray = "JdeB"
$avArray = "Tylo"
Local $avArray1
$avArray1 = "aa"
$avArray1 = "bb"
$avArray1 = "cc"
$avArray1 = "JdeB"
$avArray1 = "Tylo"
MsgBox(1,1,_ArrayBinarySearch($avArray1,"JdeB"))
MsgBox(1,1,_ArrayBinarySearch($avArray,"李四"))
MsgBox(1,1,_ArrayBinarySearch($avArray,"JdeB"))结果:
3
-1
-1 我是来参观的 我试了,确实是这样的,如果将数组中的内容转换成二进制再搜索不知道是什么结果。 ArrayBinarySearch使用前必须排序,否则改用ArraySearch#include <array.au3>
Local $avArray = ["hello","李四","王五","JdeB","Tylo"]
Local $avArray1
$avArray1 = "aa"
$avArray1 = "bb"
$avArray1 = "cc"
$avArray1 = "JdeB"
$avArray1 = "Tylo"
MsgBox(1,1,_ArrayBinarySearch($avArray1,"JdeB"))
$t = _ArraySearch($avArray,"王五")
If @error Then
MsgBox(1,1,@error)
Else
MsgBox(1,1,$t)
EndIf
_ArraySort($avArray)
_ArrayDisplay($avArray, "排序后")
MsgBox(1,1,_ArrayBinarySearch($avArray,"王五")) {:face (245):} 连数字串也不行#include <array.au3>
Local $avArray
$avArray = "张三"
$avArray = "李四"
$avArray = "王五"
$avArray = "JdeB"
$avArray = "Tylo"
Local $avArray1
$avArray1 = "aa"
$avArray1 = "bb"
$avArray1 = "cc"
$avArray1 = "1101"
$avArray1 = "Tylo"
MsgBox(1,1,_ArrayBinarySearch($avArray1,"Tylo"))
MsgBox(1,1,_ArrayBinarySearch($avArray1,"1101"))
MsgBox(1,1,_ArrayBinarySearch($avArray,"李四"))
MsgBox(1,1,_ArrayBinarySearch($avArray,"JdeB"))
{:face (239):}
原来如此,帮助里有:
注意
当执行二进制搜索时,内容必须先排序. 否则将返回未定义结果.
没注意看。。。汗 我是来参观的
dwilly 发表于 2010-12-19 08:45 http://www.autoitx.com/images/common/back.gif
又遇到你了,你就是那个版主说金钱和贡献都成负数的传奇人物......
页:
[1]