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
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
相关文章推荐
- java IO和NIO的场景选择
- 动态规划 —— 最长递增子序列(LIS)
- ftp服务安装
- .NET开发常用知识点总结汇总
- leetcode [python] 【338】Counting Bits
- CSS3的基本介绍
- JAVA学习之---泛型
- 循环法一
- 5个价值观
- php中socket的使用
- Global.asax 文件是什么
- 沙盒操作相关
- git revert .vs. git reset .vs. git rebase
- 随机生成10个数,并求出这10个数的和
- HP-Socket国产优秀socket通信组件推荐
- 第十节 项目风险、收尾、知识产权管理
- 关于Firefox 调试 easyUI 报jquery tree方法未定义错误
- vb5
- 平台对接SQL server 数据库
- Linux IP代理筛选系统(shell+proxy)