..:Welcome to My Blog:..

Clock

Entri Populer

Powered By Blogger

Total Tayangan Halaman

Pages

Bubble VB

Sub BUBBLE01()
        Dim X, Y, C As Integer
        For X = 1 To N - 1
            For Y = X + 1 To N
                If AR(X) < AR(Y) Then
                    C = AR(X) : AR(X) = AR(Y) : AR(Y) = C
                End If
            Next
        Next
    End Sub




    Sub BUBBLE02()
        Dim X, Y, C As Integer
        For X = 1 To N
            For Y = 1 To N - X
                If AR(Y) > AR(Y + 1) Then
                    C = AR(Y) : AR(Y) = AR(Y + 1) : AR(Y + 1) = C
                End If
            Next
        Next
    End Sub




    Sub BUBBLEFLAG()
        Dim X, Y, F, C As Integer
        Do
            X = X + 1
            F = 0
            For Y = 1 To N - X
                If AR(Y) < AR(Y + 1) Then
                    C = AR(Y) : AR(Y) = AR(Y + 1) : AR(Y + 1) = C
                    F = 1
                End If
            Next Y
        Loop Until F = 0
    End Sub




    Sub SHELLSORT()
        Dim G, F, C As Integer
        G = N \ 2
        While G > 0
            Do
                F = 0
                For X = 1 To N - G
                    If AR(X) < AR(X + G) Then
                        C = AR(X)
                        AR(X) = AR(X + G)
                        AR(X + G) = C
                        F = 1
                    End If
                Next
            Loop Until F = 0
            G = G \ 2
        End While
    End Sub




    Sub SELECTSORT()
        Dim X, S, Y, C As Integer
        For X = 1 To N - 1
            S = X
            For Y = X + 1 To N
                If AR(S) > AR(Y) Then S = Y
            Next Y
            If S <> X Then
                C = AR(S)
                AR(S) = AR(X)
                AR(X) = C
            End If
        Next X
    End Sub

0 komentar:

Posting Komentar

Pengikut