Private Sub Command1_Click()
Me.Font.Size = 30
Dim a(10) As Integer
Dim i As Integer
Dim j As Integer
For i = 1 To 10
a(i) = Int(Rnd * 100)
Print a(i)
Next i
Print
For i = 1 To 9
For j = i + 1 To 10
If a(j) > a(i) Then
swap a(i), a(j)
End If
Next j
Next i
For i = 1 To 10
Print a(i)
Next i
End Sub
Private Sub swap(a As Integer, b As Integer)
Dim t As Integer
t = a
a = b
b = t
End Sub
![]()
冒泡排序法,
你说难不难,
容易不容易,
主要看个人,
懂就不难 ,
不懂就难,
开始时觉得难,
学会了就不难,
不过还是要自己研究。
就像师傅领进门,
修行看个人。
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
Dim a(10) As Integer
Dim i As Integer
Dim j As Integer
For i = 1 To 10
a(i) = Int(Rnd * 100)
Print a(i)
Next i
For i = 1 To 9
For j = i + 1 To 10
If a(j) > a(i) Then
swap a(i), a(j)
End If
Next j
Next i
For i = 1 To 10
Print a(i)
Next i
End Sub
Private Sub swap(a As Integer, b As Integer)
Dim t As Integer
t = a
a = b
b = t
End Sub
冒泡排序法,
你说难不难,
容易不容易,
主要看个人,
懂就不难 ,
不懂就难,
开始时觉得难,
学会了就不难,
不过还是要自己研究。
就像师傅领进门,
修行看个人。
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)