9.3 Êý×éÓ¦ÓÃÀýÌâ(¸ù¾Ýʱ¼ä¿ÉÒÔÑ¡ÔñÒ»¸ö½²!) ¸ù¾ÝÐèÒª£¬Ñ¡Ôñ1£2µÀÏÂÃæµÄÌâÄ¿£¬¸øÑ§Éú½²Çå³þËã·¨µÄ˼Ï룡
1 ÅÅÐò
Àý5-3 Ñ¡ÔñÅÅÐò·¨ Ö±½ÓÅÅÐò·¨
Option Explicit
Option Base 1
Private Sub CmdSort_Click()
Dim Sort(10) As Integer, Temp As Integer Dim I As Integer, J As Integer Randomize For I = 1 To 10
Sort(I) = Int(Rnd * (100 - 1)) + 1 Text1 = Text1 & Str(Sort(I)) Next I
For I = 1 To 9
For J = I + 1 To 10
If Sort(I) > Sort(J) Then Temp = Sort(I) Sort(I) = Sort(J) Sort(J) = Temp
End If Next J
Text2 = Text2 & Str(Sort(I)) Next I
Text2 = Text2 & Str(Sort(10)) End Sub
Option Explicit Option Base 1
Private Sub CmdSort_Click()
Dim Sort(10) As Integer, Temp As Integer Dim I As Integer, J As Integer Dim Pointer As Integer Randomize For I = 1 To 10
Sort(I) = Int(Rnd * (100 - 1)) + 1 Text1 = Text1 & Str(Sort(I)) Next I
For I = 1 To 9 Pointer = I
For J = I + 1 To 10
If Sort(Pointer) > Sort(J) Then Pointer = J End If Next J
If I <> Pointer Then Temp = Sort(I) Sort(I) = Sort(Pointer) Sort(Pointer) = Temp End If
Text2 = Text2 & Str(Sort(I)) Next I
Text2 = Text2 & Str(Sort(10))
End Sub
2 ²éÕÒ
Àý£º5-4 ˳Ðò²éÕÒ³ÌÐò £¨½çÃæ¼ûP105£© ÏȽéÉÜFor Each ¨Cnext ½á¹¹µÄÓï¾ä£º Option Explicit
Option Base 1 Dim Search As Variant