实现上述功能的VB程序如下,但加框处代码有错,请改正。
Dim n As Integer,a(1 To 100)As Integer
Private Sub Command1_Click()
’该段程序用于随机产生n个整数,存储在数组a中,并显示在列表框list1中,代码略
End Sub
Private Sub Command2 Click()
Dim i As Integer,j As Integer,tmp As Integer
List2.Clear
tmp=1
For i=1 To n-1
For j=n To i+1 Step-1
If Then ‘①
a(j)=a(j)+a(j-1)
a(j-1)=a(j)-a(j-1)
a(j)=a(j)-a(j-1)
End If
Next j
‘②
Next i
For i=1 To n
List2.AddItem Str(a(i))
Next i
End Sub
① ②