问题 填空题

设有如下程序: Private Sub search(a()As Variant,ByVal key As Variant,index%) Dim I% For i=LBound(A) To UBound(A) If key=a(I)Thenindex=IExit Sub End If Next I index=-1 End Sub Private Sub Form_Load() Show Dim b() As Variant Dim n As Integer b=Array(1,3,5,7,9,11,13,15) Call search(b,11,n) Print n End Sub 程序运行后,输出结果是 【6】

答案

参考答案:E

解析: 该过程实现顺序查找的功能,即从数组的第0个元素开始,依次和关键字key进行比较,如果相等,则返回其下标并结束查找。Visual Basic中默认数组元素的下标从。开始,因此11是第6个元素,其下标为5。

材料题
单项选择题