Selection sort

Selection Sort

Sorting Menggunakan Metode Selection Sort!!!

Tuttorial Membuat Sorting Dengan Bahasa Pemograman VB.net Visual Studio 



Pertama-tama kita buat project baru click new project



Lalu Pilih Console Application 




Lalu Akan tampil seperti ini



Lalu tulis Source kode program Selection Sort seperti berikut

Module Module1
    Sub Main(args As String())
        Console.WriteLine(" |====================================|")
        Console.WriteLine(" |        -STMIK YADIKA BANGIL-       |")
        Console.WriteLine(" |  Nama : Khaedar Al hamid           |")
        Console.WriteLine(" |  NIM  : 119229051                  |")
        Console.WriteLine(" |  Kelas: 2B                         |")
        Console.WriteLine(" |====================================|")

        Dim a, b, c, d As Integer

        Console.WriteLine("++++++++++++++++++++")
        Console.WriteLine("!!!!!Ascending!!!!!!")
        Console.WriteLine("++++++++++++++++++++")
        Console.WriteLine()
        Console.Write("Masukkan Jumlah Elemennya :")
        a = CInt(Console.ReadLine())
        Dim sorting(a) As Integer

        b = 0
        While b <= a - 1
            Console.Write("Masukan Elemen " & (b + 1).ToString & ": ")
            sorting(b) = CInt(Console.ReadLine())
            b = b + 1
        End While

        Console.WriteLine()
        Console.WriteLine("+++++++++++++++++++")
        Console.WriteLine(" Sebelum diurutkan ")
        Console.WriteLine("+++++++++++++++++++")

        b = 0
        While b <= a - 1
            Console.WriteLine(sorting(b) & " ")
            b = b + 1
        End While

        Console.WriteLine()
        b = 0
        c = 1
        While b <= a - 2
            c = b + 1
            While c <= a - 1
                If sorting(b) > sorting(c) Then
                    d = sorting(b)
                    sorting(b) = sorting(c)
                    sorting(c) = d
                End If
                c = c + 1
            End While
            b = b + 1
        End While

        Console.WriteLine("+++++++++++++++++++")
        Console.WriteLine(" Sesudah diurutkan ")
        Console.WriteLine("+++++++++++++++++++")
        b = 0
        While b <= a - 1
            Console.WriteLine(sorting(b) & " ")
            b = b + 1
        End While

Console.ReadLine()
    End Sub

End Module

Lalu Akan Tampil Seperti Gambar  Berikut ini!!!





Sekian Tuttorial dari saya apabila ada kesalahan mohon dimaafkan sekian Terimakasih...


Komentar

Posting Komentar