先遍歷數(shù)組:
成都創(chuàng)新互聯(lián)公司專注于企業(yè)成都全網(wǎng)營(yíng)銷、網(wǎng)站重做改版、扶風(fēng)網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5響應(yīng)式網(wǎng)站、商城網(wǎng)站開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為扶風(fēng)等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
for?i?=?0?to?Ubound(數(shù)組)
...
next
再把中間的...替換成:
if?數(shù)組(i)?=?特定的字符?then?msgbox?"找到鳥,當(dāng)前是:數(shù)組"??i
先把strA排序,
ind = 2
if len(strA) = 0 then return
strB(1) = strA(1)
for each s in strA
if (strA(ind) strA(ind - 1) then
count = 0
strB(ind) = strA(ind)
else
strB(ind) = strA(ind - 1)
end if
ind = ind + 1
next s
vb語(yǔ)法忘了。。。大概是這么個(gè)意思吧。。。。 排序N LOG N,后面是線性的N,所以總共是NLOGN
'''這個(gè)函數(shù)功能就是用來(lái)把數(shù)組轉(zhuǎn)為string的格式'''如byte()={1,2,3,4,5,6}轉(zhuǎn)化后變?yōu)?,1,2,3,4,5,6,"Function ByteArrayToString(bytes() As Byte) As String Dim s As String = "" For i As Integer = 0 To bytes.Length s = Convert.ToString(bytes(i)) "," Next Return “," sEnd Function Sub Search()Dim a as byte()={1,2,3,4,5,6}
Dim b as byte()={2,3,4}
Dim astr As String = ByteArrayToString(a)Dim bstr As String = ByteArrayToString(b)Dim index As Integer = astr.IndexOf(bstr) '這個(gè)index就是b數(shù)組在a數(shù)組的位置,下標(biāo)從0開始,不過(guò)記得處理下逗號(hào),因?yàn)檫@時(shí)候是字符串。'''如果index小于0說(shuō)明沒(méi)有匹配內(nèi)容End Sub 現(xiàn)在說(shuō)明下ByteArrayToString為什么要在字符串開頭加個(gè)",",如果不加,可能出現(xiàn)a="1,23,4,5,6,", b="3,4,5,",結(jié)果導(dǎo)致查詢位置錯(cuò)誤,匹配了a的位置