高校等考试题天天练二级VB]10月22日
分类: 计算机
时间: 2022-09-24 04:30:44
作者: 全国等级考试资料网
知识点:for语句和if语句嵌套
Private Sub Command1_Click()
Dim a As Variant
a = Array(4, 2, 3, 1, 5)
For m = 4 To 0 Step -1
For n = 1 To m
If a(m) < a(m - n) Then
t = a(m)
a(m) = a(m - n)
a(m - n) = t
End If
Next n
Next m
For m = 0 To 4
Print a(m);
Next m
End Sub
Private Sub Command1_Click()
Dim a As Variant
a = Array(4, 2, 3, 1, 5)
For m = 4 To 0 Step -1
For n = 1 To m
If a(m) < a(m - n) Then
t = a(m)
a(m) = a(m - n)
a(m - n) = t
End If
Next n
Next m
For m = 0 To 4
Print a(m);
Next m
End Sub