Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Module Module1 Sub SelSort(ByRef x() As Integer, ByVal mulai As Integer, ByVal berhenti As Integer) Dim begin As Integer

= mulai Dim parameter As Integer = begin Dim temp As Integer, i As Integer If mulai < berhenti Then For i = begin + 1 To berhenti + 1 If x(i) < x(parameter) Then parameter = i Next i temp = x(begin) x(begin) = x(parameter) x(parameter) = temp SelSort(x, mulai + 1, berhenti) End If End Sub Sub Main() Dim I, jumlah, m As Integer Dim x() As Integer = {2, 5, 3, 7, 9, 4, 0} Console.WriteLine("Masukan Awal : ") For I = 0 To x.GetUpperBound(0) Console.Write("{0} ", x(I)) Next I SelSort(x, 0, x.GetUpperBound(0) - 1) Console.WriteLine("{0}Hasil Selection Short : ", Chr(10)) For I = 0 To x.GetUpperBound(0) Console.Write("{0} ", x(I)) Next I Console.WriteLine(vbLf) Console.WriteLine("Jumlah Data : ") For I = 0 To x.GetUpperBound(0) jumlah += 1 Next I Console.WriteLine(jumlah) Console.WriteLine(vbLf) Console.WriteLine("Nilai Minimal : ") Console.WriteLine(x(0)) Console.WriteLine(vbLf) Console.WriteLine("Nilai Maksimal : ") Console.WriteLine(x(jumlah - 1)) Console.Read() End Sub End Module

You might also like