vb.net搜索数组,c语言数组搜索
vb.net 从数组{5,7,11,13,17,19}中取一个数,取三次(可以是相同的数),三次之和有几个值?求代码!
Sub 和()
目前创新互联公司已为成百上千的企业提供了网站建设、域名、网络空间、网站改版维护、企业网站设计、佳县网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
Dim Arr, Dic As Object, i, j, k
Set Dic = CreateObject("Scripting.Dictionary")
Arr = Array(5, 7, 11, 13, 17, 19)
For i = 0 To UBound(Arr)
For j = 0 To UBound(Arr)
For k = 0 To UBound(Arr)
Dic(Arr(i) + Arr(j) + Arr(k)) = ""
Next k
Next j
Next i
MsgBox Dic.Count
Set Dic = Nothing
End Sub
结果为22种不同的和值。
vb.net如何在数组中查找数组?
'''这个函数功能就是用来把数组转为string的格式'''如byte()={1,2,3,4,5,6}转化后变为",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) '这个index就是b数组在a数组的位置,下标从0开始,不过记得处理下逗号,因为这时候是字符串。'''如果index小于0说明没有匹配内容End Sub 现在说明下ByteArrayToString为什么要在字符串开头加个",",如果不加,可能出现a="1,23,4,5,6,", b="3,4,5,",结果导致查询位置错误,匹配了a的位置
在asp VB.NET怎么查找一维数组中特定字符串
先遍历数组:
for i = 0 to Ubound(数组)
...
next
再把中间的...替换成:
if 数组(i) = 特定的字符 then msgbox "找到鸟,当前是:数组" i
分享题目:vb.net搜索数组,c语言数组搜索
转载来源:http://azwzsj.com/article/hdcohe.html