vb怎么使用选择法对一个数组进行排序?
展开全部
Private Sub Command1_Click()
Dim x(1 To 5) As Integer
Dim n, i, j As Integer
n = 5
For i = 1 To n
x(i) = Val(InputBox("请输入"))
Next
For i = 1 To n - 1
For j = i + 1 To n
If x(i) > x(j) Then
temp = x(i): x(i) = x(j): x(j) = temp
End If
Next j
Next i
For i = 1 To 5
Print x(i);
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询