15电气李丹【给15个数字排序】
2016-03-24 17:47
316 查看
给15个数字排序
双击桌面上的VB6.0,点击工具箱中command button图标,在窗体中单击拖动划出一个按钮,双击该按钮,输入代码。
代码如下:
Private Sub Command1_Click()
Cls
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer
Dim n As Integer
Dim o As Integer
Dim swap As Integer
a = Int(Rnd * 1000)
b = Int(Rnd * 1000)
c = Int(Rnd * 1000)
d = Int(Rnd * 1000)
e = Int(Rnd * 1000)
f = Int(Rnd * 1000)
g = Int(Rnd * 1000)
h = Int(Rnd * 1000)
i = Int(Rnd * 1000)
j = Int(Rnd * 1000)
k = Int(Rnd * 1000)
l = Int(Rnd * 1000)
m = Int(Rnd * 1000)
n = Int(Rnd * 1000)
o = Int(Rnd * 1000)
If a < b Then
Call swap(a, b)
End If
If a < c Then
Call swap(a, c)
End If
If a < d Then
Call swap(a, d)
End If
If a < e Then
Call swap(a, e)
End If
If a < f Then
Call swap(a, f)
End If
If a < g Then
Call swap(a, g)
End If
If a < h Then
Call swap(a, h)
End If
If a < i Then
Call swap(a, i)
End If
If a < j Then
Call swap(a, j)
End If
If a < k Then
Call swap(a, k)
End If
If a < l Then
Call swap(a, l)
End If
If a < m Then
Call swap(a, m)
End If
If a < n Then
Call swap(a, n)
End If
If a < o Then
Call swap(a, o)
End If
If b < c Then
Call swap(b, c)
End If
If b < d Then
Call swap(b, d)
End If
If b < e Then
Call swap(b, e)
End If
If b < f Then
Call swap(b, f)
End If
If b < g Then
Call swap(b, g)
End If
If b < h Then
Call swap(b, h)
End If
If b < i Then
Call swap(b, i)
End If
If b < j Then
Call swap(b, j)
End If
If b < k Then
Call swap(b, k)
End If
If b < l Then
Call swap(b, l)
End If
If b < m Then
Call swap(b, m)
End If
If b < n Then
Call swap(b, n)
End If
If b < o Then
Call swap(b, o)
End If
If c < d Then
Call swap(c, d)
End If
If c < e Then
Call swap(c, e)
End If
If c < f Then
Call swap(c, f)
End If
If c < g Then
Call swap(c, g)
End If
If c < h Then
Call swap(c, h)
End If
If c < i Then
Call swap(c, i)
End If
If c < j Then
Call swap(c, j)
End If
If c < k Then
Call swap(c, k)
End If
If c < l Then
Call swap(c, l)
End If
If c < m Then
Call swap(c, m)
End If
If c < n Then
Call swap(c, n)
End If
If c < o Then
Call swap(c, o)
End If
If d < e Then
Call swap(d, e)
End If
If d < f Then
Call swap(d, f)
End If
If d < g Then
Call swap(d, g)
End If
If d < h Then
Call swap(d, h)
End If
If d < i Then
Call swap(d, i)
End If
If d < j Then
Call swap(d, j)
End If
If d < k Then
Call swap(d, k)
End If
If d < l Then
Call swap(d, l)
End If
If d < m Then
Call swap(d, m)
End If
If d < n Then
Call swap(d, n)
End If
If d < o Then
Call swap(d, o)
End If
If e < f Then
Call swap(e, f)
End If
If e < g Then
Call swap(e, g)
End If
If e < h Then
Call swap(e, h)
End If
If e < i Then
Call swap(e, i)
End If
If e < j Then
Call swap(e, j)
End If
If e < k Then
Call swap(e, k)
End If
If e < l Then
Call swap(e, l)
End If
If e < m Then
Call swap(e, m)
End If
If e < n Then
Call swap(e, n)
End If
If e < o Then
Call swap(e, o)
End If
If f < g Then
Call swap(f, g)
End If
If f < h Then
Call swap(f, h)
End If
If f < i Then
Call swap(f, i)
End If
If f < j Then
Call swap(f, j)
End If
If f < k Then
Call swap(f, k)
End If
If f < l Then
Call swap(f, l)
End If
If f < m Then
Call swap(f, m)
End If
If f < n Then
Call swap(f, n)
End If
If f < o Then
Call swap(f, o)
End If
If g < h Then
Call swap(g, h)
End If
If g < i Then
Call swap(g, i)
End If
If g < j Then
Call swap(g, j)
End If
If g < k Then
Call swap(g, k)
End If
If g < l Then
Call swap(g, l)
End If
If g < m Then
Call swap(g, m)
End If
If g < n Then
Call swap(g, n)
End If
If g < o Then
Call swap(g, o)
End If
If h < i Then
Call swap(h, i)
End If
If h < j Then
Call swap(h, j)
End If
If h < k Then
Call swap(h, k)
End If
If h < l Then
Call swap(h, l)
End If
If h < m Then
Call swap(h, m)
End If
If h < n Then
Call swap(h, n)
End If
If h < o Then
Call swap(h, o)
End If
If i < j Then
Call swap(i, j)
End If
If i < k Then
Call swap(i, k)
End If
If i < l Then
Call swap(i, l)
End If
If i < m Then
Call swap(i, m)
End If
If i < n Then
Call swap(i, n)
End If
If i < o Then
Call swap(i, o)
End If
If j < k Then
Call swap(j, k)
End If
If j < l Then
Call swap(h, l)
End If
If j < m Then
Call swap(j, m)
End If
If j < n Then
Call swap(j, n)
End If
If j < o Then
Call swap(j, o)
End If
If k < l Then
Call swap(k, l)
End If
If k < m Then
Call swap(k, m)
End If
If k < n Then
Call swap(k, n)
End If
If k < o Then
Call swap(k, o)
End If
If l < m Then
Call swap(l, m)
End If
If l < n Then
Call swap(l, n)
End If
If l < o Then
Call swap(l, o)
End If
If m < n Then
Call swap(m, n)
End If
If m < o Then
Call swap(m, o)
End If
If n < o Then
Call swap(n, o)
End If
Print &","&b&","&c&","&d&","&e&","&f&","&g&","&h&","&i&","&j&","&k&","&l&","&m&","&n&","&o
End Sub
Private Sub swap(x As Integer,y As Integer)
Dim temp As Integer
If x<y Then
temp=x
x=y
y=temp
End if
End Sub
输入完毕,点击运行,点击按钮即可看到15个数字排序结果。
双击桌面上的VB6.0,点击工具箱中command button图标,在窗体中单击拖动划出一个按钮,双击该按钮,输入代码。
代码如下:
Private Sub Command1_Click()
Cls
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer
Dim n As Integer
Dim o As Integer
Dim swap As Integer
a = Int(Rnd * 1000)
b = Int(Rnd * 1000)
c = Int(Rnd * 1000)
d = Int(Rnd * 1000)
e = Int(Rnd * 1000)
f = Int(Rnd * 1000)
g = Int(Rnd * 1000)
h = Int(Rnd * 1000)
i = Int(Rnd * 1000)
j = Int(Rnd * 1000)
k = Int(Rnd * 1000)
l = Int(Rnd * 1000)
m = Int(Rnd * 1000)
n = Int(Rnd * 1000)
o = Int(Rnd * 1000)
If a < b Then
Call swap(a, b)
End If
If a < c Then
Call swap(a, c)
End If
If a < d Then
Call swap(a, d)
End If
If a < e Then
Call swap(a, e)
End If
If a < f Then
Call swap(a, f)
End If
If a < g Then
Call swap(a, g)
End If
If a < h Then
Call swap(a, h)
End If
If a < i Then
Call swap(a, i)
End If
If a < j Then
Call swap(a, j)
End If
If a < k Then
Call swap(a, k)
End If
If a < l Then
Call swap(a, l)
End If
If a < m Then
Call swap(a, m)
End If
If a < n Then
Call swap(a, n)
End If
If a < o Then
Call swap(a, o)
End If
If b < c Then
Call swap(b, c)
End If
If b < d Then
Call swap(b, d)
End If
If b < e Then
Call swap(b, e)
End If
If b < f Then
Call swap(b, f)
End If
If b < g Then
Call swap(b, g)
End If
If b < h Then
Call swap(b, h)
End If
If b < i Then
Call swap(b, i)
End If
If b < j Then
Call swap(b, j)
End If
If b < k Then
Call swap(b, k)
End If
If b < l Then
Call swap(b, l)
End If
If b < m Then
Call swap(b, m)
End If
If b < n Then
Call swap(b, n)
End If
If b < o Then
Call swap(b, o)
End If
If c < d Then
Call swap(c, d)
End If
If c < e Then
Call swap(c, e)
End If
If c < f Then
Call swap(c, f)
End If
If c < g Then
Call swap(c, g)
End If
If c < h Then
Call swap(c, h)
End If
If c < i Then
Call swap(c, i)
End If
If c < j Then
Call swap(c, j)
End If
If c < k Then
Call swap(c, k)
End If
If c < l Then
Call swap(c, l)
End If
If c < m Then
Call swap(c, m)
End If
If c < n Then
Call swap(c, n)
End If
If c < o Then
Call swap(c, o)
End If
If d < e Then
Call swap(d, e)
End If
If d < f Then
Call swap(d, f)
End If
If d < g Then
Call swap(d, g)
End If
If d < h Then
Call swap(d, h)
End If
If d < i Then
Call swap(d, i)
End If
If d < j Then
Call swap(d, j)
End If
If d < k Then
Call swap(d, k)
End If
If d < l Then
Call swap(d, l)
End If
If d < m Then
Call swap(d, m)
End If
If d < n Then
Call swap(d, n)
End If
If d < o Then
Call swap(d, o)
End If
If e < f Then
Call swap(e, f)
End If
If e < g Then
Call swap(e, g)
End If
If e < h Then
Call swap(e, h)
End If
If e < i Then
Call swap(e, i)
End If
If e < j Then
Call swap(e, j)
End If
If e < k Then
Call swap(e, k)
End If
If e < l Then
Call swap(e, l)
End If
If e < m Then
Call swap(e, m)
End If
If e < n Then
Call swap(e, n)
End If
If e < o Then
Call swap(e, o)
End If
If f < g Then
Call swap(f, g)
End If
If f < h Then
Call swap(f, h)
End If
If f < i Then
Call swap(f, i)
End If
If f < j Then
Call swap(f, j)
End If
If f < k Then
Call swap(f, k)
End If
If f < l Then
Call swap(f, l)
End If
If f < m Then
Call swap(f, m)
End If
If f < n Then
Call swap(f, n)
End If
If f < o Then
Call swap(f, o)
End If
If g < h Then
Call swap(g, h)
End If
If g < i Then
Call swap(g, i)
End If
If g < j Then
Call swap(g, j)
End If
If g < k Then
Call swap(g, k)
End If
If g < l Then
Call swap(g, l)
End If
If g < m Then
Call swap(g, m)
End If
If g < n Then
Call swap(g, n)
End If
If g < o Then
Call swap(g, o)
End If
If h < i Then
Call swap(h, i)
End If
If h < j Then
Call swap(h, j)
End If
If h < k Then
Call swap(h, k)
End If
If h < l Then
Call swap(h, l)
End If
If h < m Then
Call swap(h, m)
End If
If h < n Then
Call swap(h, n)
End If
If h < o Then
Call swap(h, o)
End If
If i < j Then
Call swap(i, j)
End If
If i < k Then
Call swap(i, k)
End If
If i < l Then
Call swap(i, l)
End If
If i < m Then
Call swap(i, m)
End If
If i < n Then
Call swap(i, n)
End If
If i < o Then
Call swap(i, o)
End If
If j < k Then
Call swap(j, k)
End If
If j < l Then
Call swap(h, l)
End If
If j < m Then
Call swap(j, m)
End If
If j < n Then
Call swap(j, n)
End If
If j < o Then
Call swap(j, o)
End If
If k < l Then
Call swap(k, l)
End If
If k < m Then
Call swap(k, m)
End If
If k < n Then
Call swap(k, n)
End If
If k < o Then
Call swap(k, o)
End If
If l < m Then
Call swap(l, m)
End If
If l < n Then
Call swap(l, n)
End If
If l < o Then
Call swap(l, o)
End If
If m < n Then
Call swap(m, n)
End If
If m < o Then
Call swap(m, o)
End If
If n < o Then
Call swap(n, o)
End If
Print &","&b&","&c&","&d&","&e&","&f&","&g&","&h&","&i&","&j&","&k&","&l&","&m&","&n&","&o
End Sub
Private Sub swap(x As Integer,y As Integer)
Dim temp As Integer
If x<y Then
temp=x
x=y
y=temp
End if
End Sub
输入完毕,点击运行,点击按钮即可看到15个数字排序结果。
相关文章推荐
- 对理想团队模式构建的设想以及对软件流程的理解
- NET 分布式架构开发项目实战
- Delphi实现窗口一直在桌面工作区内显示(重写WM_WINDOWPOSCHANGING消息)
- L8-DOM操作应用
- Android入门(一)
- PXE批量安装操作系统
- java测试方法和代码的运行时间
- 教育技术余晓红
- 命令行删除tomcat
- C++作业2
- hdu1234开门人和关门人
- Java学习笔记(三)之― Java中的变量、数据类型、运算符、类型转换
- CBC和CTR解密模式——C++实现
- 感慨
- 比大小
- Android 通过httpclient请求web服务器,并解决用户登录session保持
- sphinx站内搜索
- iOS设计模式之一:MVC模式和单例模式
- [Java代码] 【WebService】——CXF整合Spring
- 13.判断登录