您的位置:首页 > 其它

冒泡排序法

2016-05-12 18:12 363 查看
[align=center]Private Sub Command1_Click()
endtime = Now
passtime = endtime - startime
Label2.Caption = Format(endtime, "hh:mm:ss")
Label3.Caption = Format(passtime, "hh:mm:ss")
Command2.Enabled = False
Command1.Enabled = True

End Sub

Private Sub Command2_Click()
Cls
Dim a(100000) As Integer
Dim i As Integer
Dim j As Integer
 startime = Now
 Label1.Caption = Format(startime, "hh:mm:ss")
[/align]
 Label2.Caption = ""
 Label3.Caption = ""
 Command1.Enabled = False
 Command2.Enabled = True
For i = 1 To 100000
a(i) = Int(Rnd * 100)
Print a(i);
Next i
Print
For i = 1 To 99999
    For j = i + 1 To 100000
        If a(j) > a(i) Then
        swap a(i), a(j)
        End If
    Next j
 Next i
 For i = 1 To 100000
 Print a(i);
 Next i

 End Sub
 
Private Sub swap(a As Integer, b As Integer)
Dim t As Integer
t = a
a = b
b = t
End Sub

Private Sub Command1_Click()

endtime = Now

passtime = endtime - startime

Label2.Caption = Format(endtime, "hh:mm:ss")

Label3.Caption = Format(passtime, "hh:mm:ss")

Command2.Enabled = False

Command1.Enabled = True

End Sub

Private Sub Command2_Click()

Cls

Dim a(100000) As Integer

Dim i As Integer

Dim j As Integer

 startime = Now

 Label1.Caption = Format(startime, "hh:mm:ss")

 Label2.Caption = ""

 Label3.Caption = ""

 Command1.Enabled = False

 Command2.Enabled = True

For i = 1 To 100000

a(i) = Int(Rnd * 100)

Print a(i);

Next i

Print

For i = 1 To 99999

    For j = i + 1 To 100000

        If a(j) > a(i) Then

        swap a(i), a(j)

        End If

    Next j

 Next i

 For i = 1 To 100000

 Print a(i);

 Next i

 End Sub

 

Private Sub swap(a As Integer, b As Integer)

Dim t As Integer

t = a

a = b

b = t

End Sub

Private Sub Command1_Click()

endtime = Now

passtime = endtime - startime

Label2.Caption = Format(endtime, "hh:mm:ss")

Label3.Caption = Format(passtime, "hh:mm:ss")

Command2.Enabled = False

Command1.Enabled = True

End Sub

Private Sub Command2_Click()

Cls

Dim a(100000) As Integer

Dim i As Integer

Dim j As Integer

 startime = Now

 Label1.Caption = Format(startime, "hh:mm:ss")

 Label2.Caption = ""

 Label3.Caption = ""

 Command1.Enabled = False

 Command2.Enabled = True

For i = 1 To 100000

a(i) = Int(Rnd * 100)

Print a(i);

Next i

Print

For i
9b2b
= 1 To 99999

    For j = i + 1 To 100000

        If a(j) > a(i) Then

        swap a(i), a(j)

        End If

    Next j

 Next i

 For i = 1 To 100000

 Print a(i);

 Next i

 End Sub

 

Private Sub swap(a As Integer, b As Integer)

Dim t As Integer

t = a

a = b

b = t

End Sub

Private Sub Command1_Click()

endtime = Now

passtime = endtime - startime

Label2.Caption = Format(endtime, "hh:mm:ss")

Label3.Caption = Format(passtime, "hh:mm:ss")

Command2.Enabled = False

Command1.Enabled = True

End Sub

Private Sub Command2_Click()

Cls

Dim a(100000) As Integer

Dim i As Integer

Dim j As Integer

 startime = Now

 Label1.Caption = Format(startime, "hh:mm:ss")

 Label2.Caption = ""

 Label3.Caption = ""

 Command1.Enabled = False

 Command2.Enabled = True

For i = 1 To 100000

a(i) = Int(Rnd * 100)

Print a(i);

Next i

Print

For i = 1 To 99999

    For j = i + 1 To 100000

        If a(j) > a(i) Then

        swap a(i), a(j)

        End If

    Next j

 Next i

 For i = 1 To 100000

 Print a(i);

 Next i

 End Sub

 

Private Sub swap(a As Integer, b As Integer)

Dim t As Integer

t = a

a = b

b = t

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: