vb用自定义函数过程实现数组的选择法排序,急求!谢谢!!
2个回答
展开全部
Dim a(100) As Integer
Private Sub Command1_Click()
Dim n As Integer
Randomize
n = InputBox("N=")
Print "N="; n
Print "原来的数组:"
For i = 0 To n - 1
a(i) = Int(Rnd * 100)
Print Tab((i Mod 10 + 1) * 4); a(i);
Next i
Sort (n)
End Sub
Private Sub Sort(n)
For i = 0 To n - 1
k = i
For j = i + 1 To n
If a(j) > a(k) Then k = j
Next j
t = a(i): a(i) = a(k): a(k) = t
Next i
Print "排序后的数组:"
For i = 0 To n - 1
Print Tab((i Mod 10 + 1) * 4); a(i);
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询