冒泡排序
Private Sub Form_Click()
Const N = 10
Dim A(N), i, j, temp As Integer
A(0) = 1: A(1) = 3: A(2) = 5: A(3) = 7: A(4) = 9: A(5) = 6
A(6) = 12: A(7) = 8: A(8) = 4: A(9) = 11
For i = 0 To N - 1
Print A(i);
Next
Print
For i = 0 To N - 1
For j = 0 To N - i - 1
If (A(j) > A(j + 1)) Then temp = A(j): A(j) = A(j + 1): A(j + 1) = temp
Next j
Next i
For i = 0 To N - 1
Print A(i);
Next
Print
End Sub
为什么排序后少了最后一个数?