一維陣列中不重覆資料的篩選
Dim AAA() As String = {"Ball", "Cup", "Ball", "ball", "Apple"} Dim BBB As New List(Of String) Dim i, j Dim count For i = 0 To AAA.Length - 1 count = 0 ' count 是用來計算字串出現的次數 For j = 0 To AAA.Length - 1 If AAA(i) = AAA(j) Then ' 當字串相同時,則count加1 count = count + 1 End If Next If count = 1 Then '當字串只有在陣列內只出現一次時,表示沒有重複 BBB.Add(AAA(i)) ' 將字串加入 BBB End If Next
沒有留言:
張貼留言