Pages

Search This Blog

Bubble Sorting 2


Module Ascending2
    Sub Main()
        Dim n, i, j, t As Integer
        Console.Write("Enter the number of Elements: ")
        n = CInt(Console.ReadLine())
        Dim arr(n) As Integer
        For i = 0 To n - 1
            Console.Write("Enter the " & (i + 1).ToString & "th element: ")
            arr(i) = CInt(Console.ReadLine())
        Next
        Console.WriteLine("Array Contains...")
        For i = 0 To n - 1
            Console.Write(arr(i) & " ")
        Next
        Console.WriteLine()
        For i = 0 To n - 2
            For j = 0 To n - i - 2
                If arr(j) > arr(j + 1) Then
                    t = arr(j)
                    arr(j) = arr(j + 1)
                    arr(j + 1) = t
                End If
            Next
        Next
        Console.WriteLine("Ascending Order: ")
        For i = 0 To n - 1
            Console.Write(arr(i) & " ")
        Next
        Console.ReadLine()
    End Sub

End Module

2 comments:

  1. Merkur Slots Machines - SEGATIC PLAY - Singapore
    Merkur Slot Machines. 5 star 토토 rating. ventureberg.com/ The https://septcasino.com/review/merit-casino/ Merkur Casino game was the first to feature video slots in the jancasino.com entire casino, gri-go.com

    ReplyDelete