'求第1大、第2大值 ... -- 氣泡排序基礎
Public Class Form1
Dim i, j
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a() = {2, 5, 4, 1, 3}
For j = 1 To 4
For i = 0 To 3
If a(i) > a(i + 1) Then
Dim t = a(i)
a(i) = a(i + 1)
a(i + 1) = t
End If
Next
Next j
For i = 0 To 4
MsgBox(a(i))
Next i
End Sub
End Class
沒有留言:
張貼留言