[填空题] 设有如下程序 Private Sub Search(a( )As Variant,ByVa1 key As Variant,index%) Dim I% For I=LBound(a) T

[填空题] 设有如下程序 Private Sub Search(a( )As Variant,ByVa1 key As Variant,index%) Dim I% For I=LBound(a) T,第1张

[填空题] 设有如下程序 Private Sub Search(a( )As Variant,ByVa1 key As Variant,index%) Dim I% For I=LBound(a) T

[填空题] 设有如下程序 Private Sub Search(a( )As Variant,ByVa1 key As Variant,index%) Dim I% For I=LBound(a) To UBound(a) If key=a(1) Thenindex=IExit SubEnd If Next I index=IEnd SubPrivate 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 nEnd Sub程序动行后,输出结果是 【15】

正确答案:

E

参考解析:

根据题意,Search需要在数组a( )中寻找等于key的数,如果找到了,则令In- dex等于该元素的下标值,如果没有找到,则令Index等于-1。根据,在调用Search时,11为b(8)的第6个元素,下标为5,故index为5。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5577056.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存