Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Sort

Module Module1

    Sub Main()
        Dim MyArray(9) As Single
        For i as integer = 0 To UBound(MyArray)
            MyArray(i) = Rnd()
        Next

        Dim SwapMade As Boolean = True

        While SwapMade = True
            SwapMade = False

            For i as integer = 0 To MyArray.Length - 2
                If MyArray(i) > MyArray(i + 1) Then
                    Dim temp As Single
                    temp = MyArray(i + 1)
                    MyArray(i + 1) = MyArray(i)
                    MyArray(i) = temp
                    SwapMade = True
                End If
            Next i
        End While

        For i as integer = 0 To UBound(MyArray)
            Console.WriteLine(MyArray(i))
        Next
        Console.ReadLine()
    End Sub

End Module

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.