实现上述功能的VB程序如下:
Const n=10
Dim a(1 To 10)As Integer
Private Sub Command1 Click()
For i=1 To n
‘①
List1.Addltem Str(a(i))
Next i
End Sub
Private Sub Command2 Click()
tmp=1
For i=1 To n-1
For j=n To i+1 Step-1
If >0 Then ①
t=a(j):a(j)=a(j-1):a(j-1)=t
End If
Next j
②
Next i
For i=1 To 10
List2.Addltem Str(a(i))
Next i
End Sub
① ②