怎样对5个数进行排序(冒泡)?
请教下代码
Imports System
Module Module1
Sub Main()
Dim _sortArr(5) As Integer
Dim i As Integer, j As Integer, t As Integer
For i = 1 To 5
Console.Write("请输入第" & Convert.ToString(i) & "个数: ")
_sortArr(i) = Console.ReadLine()
Next
For i = 5 To 2 Step -1
For j = 1 To i - 1
If _sortArr(j) > _sortArr(j + 1) Then
t = _sortArr(j)
_sortArr(j) = _sortArr(j + 1)
_sortArr(j + 1) = t
End If
Next
Next
Console.Write("排序后的结果是:")
Console.WriteLine()
For i = 1 To 5
Console.Write(_sortArr(i).ToString & " ")
Next
Console.ReadLine()
End Sub
End Module