请教只保留多个相同元素值中的一个数组算法
请教从一个具有多个相同元素值数组中滤出唯一值组成新的数组.例:有八个元素的数组.1,2,1,3,1,2,3,2
组成新的数组值:1,2,3每个元素都不相同.
<% Dim a(7), b(), flag Dim i, j a(0) = 1 a(1) = 2 a(2) = 1 a(3) = 3 a(4) = 1 a(5) = 2 a(6) = 3 a(7) = 2
For i = 0 To UBound(a) If i = 0 Then ReDim Preserve b(0) b(0) = a(0) Else flag = False For j = 0 To UBound(b) If a(i) = b(j) Then flag = True Exit For End If Next If flag = False Then ReDim Preserve b(UBound(b) + 1) b(UBound(b)) = a(i) End If End If Next
For i = 0 To UBound(b) 'Debug.Print b(i) Response.Write b(i) Next %>