vb程序设计从大到小排列
答案:1 悬赏:0 手机版
解决时间 2021-02-12 02:41
- 提问者网友:锁深秋
- 2021-02-11 19:24
vb程序设计从大到小排列
最佳答案
- 五星知识达人网友:独钓一江月
- 2021-02-11 19:38
这个问题的本意估计是要问数组循环排序吧,
举个例子,x y z 三个变量由大到小输出
Private Sub Command1_Click()
Dim tmp, i, j As Integer
Dim a(2) As Integer
a(0) = x
a(1) = y
a(2) = z
For i = 0 To ubound(a)-1
For j = 1 To ubound(a)
If a(i) < a(j) Then
tmp = a(i)
a(i) = a(j)
a(j) = tmp
End If
Next j
Next i '循环由大到小排序,这是核心
Print a(0)
Print a(1)
Print a(2) '逐一打印
举个例子,x y z 三个变量由大到小输出
Private Sub Command1_Click()
Dim tmp, i, j As Integer
Dim a(2) As Integer
a(0) = x
a(1) = y
a(2) = z
For i = 0 To ubound(a)-1
For j = 1 To ubound(a)
If a(i) < a(j) Then
tmp = a(i)
a(i) = a(j)
a(j) = tmp
End If
Next j
Next i '循环由大到小排序,这是核心
Print a(0)
Print a(1)
Print a(2) '逐一打印
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯