您的位置:首页 > 其它

n个随机数排列

2016-04-07 16:20 288 查看
Option Base 1

Private Sub Command1_Click()

Cls

Dim x As Integer

x = Int(Val(Me.Text1.Text))

Dim n As Integer

Dim A() As Integer

ReDim A(x)

n = LBound(A)

While n <= UBound(A)

A(n) = Int(Rnd * 1000)

n = n + 1

Wend

Dim B As Integer, M As Integer

M = LBound(A)

While M <= UBound(A) - 1

n = LBound(A)

While n <= UBound(A) - M

If A(n) < A(n + 1) Then

B = A(n): A(n) = A(n + 1): A(n + 1) = B

End If

n = n + 1

Wend

M = M + 1

Wend

n = LBound(A)

While n <= UBound(A)

Print A(n)

n = n + 1

Wend

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: