(選填:會/不會)。 Dim a(1 To 10)As Integer,b(0 To 10)As Integer Private Sub Form_Load
‘隨機產(chǎn)生10個2位奇數(shù)整數(shù) ‘代碼略 End sub Private Sub Command1_Click
Dim i As Integer,j As Integer,k As Integer,c As Integer For j=1 To 10 i=2:m=Int(Sqr(a) Do While i=i+1 Loop If①Then c=c+1 b(c)=a(j) End if temp=b(c) For k=c-1 To 1 Step-1 If temp>b(k) Then Exit For b(k+1)=b(k) Next k ② Next j For i=1 To c List2.Additem Str(b(i)) Next i End Sub
16.同分同名次程序。小明設(shè)計了一個排序程序?qū)﹄S機產(chǎn)生的n個[60,99]之間的整 數(shù)進行降序排列,然后再進行同分同名次的處理。算法的VB程序段如下,運行界面如圖所示。 Constn=10 Dim a(n) As Integer,mc(1 Ton) As Integer Private Sub Command1_Click ( ) Dim cAs Integer,i AsInteger,t As Integer Listl.Clear:List2.Clear For i=1 Ton a(i)=
Listl.AddItemStr(a(i)) Next i ′以下為排序處理 a(0)=0 i=1 Do While i<=n-1 IfThen′改錯 i=i+1 Else t=a(i):a(i)=a(i+1):a(i+1)=t c=c+1 i=i-1 End If Loop Textl.Text=Str(c) ′以下為同分同名次處理 mc(1)=1 For i=2To n If a(i)<>a(i-1)Then
Else mc(i)=mc(i-1)Next i 輸出分?jǐn)?shù)和名次,代碼略!End Sub (1)代碼“Listl.Clear”中的 Clear是