VB语言随机产生10个10-99内的整数,分别用冒泡法和选择法将数据从大到小排序并显示结果
问题描述:
VB语言随机产生10个10-99内的整数,分别用冒泡法和选择法将数据从大到小排序并显示结果
答
Private Sub Form_click()
Dim A(1 To 10)
Randomize
For I = 1 To 10
A(I) = Int(Rnd * 90) + 10
Next I
For I = 1 To 9 '选择法
p = I
For J = I + 1 To 10
If A(J) p = J
End If
Next J
tem = A(I)
A(I) = A(p)
A(p) = tem
Next I
For I = 1 To 10
A(I) = A(11 - I)
Next I
For I = 1 To 9 '冒泡法
For J = 1 To 10 - I
If A(J) > A(J + 1) Then
tem = A(I)
A(I) = A(p)
A(p) = tem
End If
Next J
Next I
For I = 1 To 10
A(I) = A(11 - I)
Next I
End Sub
已经调试过print 什么啊