Friday, December 19, 2008
Remove Duplicate Array
(klik on the image if want to see real image)
Algoritma remove duplicate array adalah algoritma untuk meremove inputan angka yang sama, contoh :
Input : 2,3,5,2,2,5,6,5,6,7
Result : 2,3,5,6,7
Di bawah ini adalah algoritma berikut sintaksnya untuk meremove duplikasi array di VB.Net / Visual Basic 2008,- silahkan dipelajari :
Public Class RemoveDuplicateArray
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
Dim angka() As Long
Dim n, i As Long
n = InputBox("Masukkan banyaknya angka ?", "Angka")
ReDim angka(n - 1)
For i = 0 To n - 1
angka(i) = InputBox("Masukkan Angka ke-" & i + 1, "Angka")
Next
For i = 0 To angka.Length - 1
ListBox1.Items.Add(angka(i))
Next
RemoveDuplicate(angka, n)
End Sub
Function RemoveDuplicate(ByVal angka() As Long, ByVal n As Long)
Dim arrlist As New ArrayList
Dim i As Integer
For i = 0 To angka.Length - 1
If Not arrlist.Contains(angka.GetValue(i)) Then
arrlist.Add(angka.GetValue(i))
End If
Next
angka = arrlist.ToArray(GetType(Long))
For i = 0 To angka.Length - 1
ListBox2.Items.Add(angka(i))
Next
End Function
End Class
Label:
[VB.Net] Basic Algorithm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment