展开全部
Option Base 1
Dim a(20)
Private Sub Form_Load()
Randomize
For i = 1 To 10
a(i) = Int(10 + 90 * Rnd)
Next
End Sub
Private Sub Command1_Click() '选择排序法
For i = 1 To 9
For j = i + 1 To 10
If a(j) > a(i) Then t = a(i): a(i) = a(j): a(j) = t
Next j
Next i
For i = 1 To 10
Print a(i);
Next
Print
End Sub
Private Sub Command2_Click() '冒泡排序法
For i = 1 To 9
For j = 10 To i + 1 Step -1
If a(j - 1) < a(j) Then
t = a(j - 1): a(j - 1) = a(j): a(j) = t
End If
Next j
Next i
For i = 1 To 10
Print a(i);
Next
Print
End Sub
Dim a(20)
Private Sub Form_Load()
Randomize
For i = 1 To 10
a(i) = Int(10 + 90 * Rnd)
Next
End Sub
Private Sub Command1_Click() '选择排序法
For i = 1 To 9
For j = i + 1 To 10
If a(j) > a(i) Then t = a(i): a(i) = a(j): a(j) = t
Next j
Next i
For i = 1 To 10
Print a(i);
Next
End Sub
Private Sub Command2_Click() '冒泡排序法
For i = 1 To 9
For j = 10 To i + 1 Step -1
If a(j - 1) < a(j) Then
t = a(j - 1): a(j - 1) = a(j): a(j) = t
End If
Next j
Next i
For i = 1 To 10
Print a(i);
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询