none
vb.net console RRS feed

All replies

  • the algorithm for bubble sort on vb.net console

    The algorithm for a bubble sort is fundamentally the same regardless of
    what kind of program it is in or what language is used. The web has
    an abundance of examples, including at Wiki.

    - Wayne


    • Edited by WayneAKing Friday, September 14, 2018 7:00 AM
    Friday, September 14, 2018 6:38 AM
  • Hi,

    code:

    Module Module1
    
        Sub Main()
            Dim arr As Integer() = {1, 2, 3, 0, 9, 11, 7, 0}
            bubbleSort(arr)
            For i = 0 To arr.Count - 1
                Console.WriteLine(arr(i))
            Next
            Console.ReadLine()
        End Sub
        Public Function bubbleSort(ByRef arr() As Integer) As Integer
            Dim i As Integer = arr.Count
            Dim temp, count As Integer
            While i > 0
                For j = 0 To i - 2
                    If arr(j) > arr(j + 1) Then
                        temp = arr(j)
                        arr(j) = arr(j + 1)
                        arr(j + 1) = temp
                    End If
                    count += 1
                Next
                i -= 1
            End While
            Return count
        End Function
    
    End Module

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 14, 2018 8:08 AM
  • Friday, September 14, 2018 9:01 AM