12.以下程序的功能是利用随即函数产生了10个0~100之间的随机整数,然后用起泡法降序排序后,输出了全部数据。请将程序补充完整。
Private Sub Form_Click()
Dim s(1 To 10) As Integer
Dim i As Integer, j As Integer, t As Integer
For i = 1 To 10
s(i) = Int(101*Rnd(1))
Next i
For i = 1 To 9
For j = ________________
If ________________ Then
t = s(j): s(j) = s(j+1) :s(j+1) = t
End If
Next j
Next i
For i = 1 To 10
Print s(i);
Next i
End Sub
13.以下程序的功能是,单击窗体,通过调用过程Search,查找数据元素15在数组中的下标值,如果没有该元素,返回值为-1。请填空。
Option Base 1
Private Sub Form_Click()
Dim a() as Variant
Dim n as integer
a = Array(2,4,6,8,10,15,17,19)
Call _______________________
Print n
End Sub
Private Sub Search(a() as Variant, ByVal key As Variant, index as Integer)
Dim i as Integer
For i = LBound(a) To UBound(a)
If ________________ Then
index = i
Exit Sub
Next i
index = -1
End Sub