第1个回答 2013-12-12
用冒泡排序方法:
Option Explicit
Option Base 1
Dim a(10) As Integer
Dim i As Integer
Dim n As Integer
Private Sub Command1_Click()
n = n + 1
If n >= 9 Then
Cls
n = 0
End If
For i = 1 To 10
a(i) = Int(Rnd * 100)
Print a(i);
Next i
Print
End Sub
Private Sub Command2_Click()
Dim j, l, t, s As Integer
n = n + 1
If n >= 9 Then
Cls
n = 0
End If
For i = 1 To 9
For j = i + 1 To 10
If a(j) < a(i) Then
t = a(j)
s = a(i)
a(i) = t
a(j) = s
End If
Next j
Next i
For l = 1 To 10
Print a(l);
Next l
Print
Print "---------------------------------------"
End Sub