题库 高中信息

题干

某查找算法的VB程序段如下:
k= Val(Text1.Text)
i=1:j=6:Label1.Caption="":f=False
Do While i<=j And Not f
m=(i+j)\2
If a(m)=k Then f= True
If a(m)>a(i) Then

If a(i)<=k And k<a(m)Then j=m-1 Else i=i+1

Else

If a(m)<k And k<=a(j)Then i=i+1 Else j=j-1

End If
Label1 Caption=Label1 Caption+ Str(a(m))
Loop
数组元素a(1)到a(6)的值依次为“58,66,72,24,35,40”,在文本框Text1中输人的值为35,执行该程序段,标签 Label1中显示的值是(   )
A.72  35B.24  35
C.72  24  35D.72  24  24  35
上一题 下一题 0.99难度 选择题 更新时间:2020-03-30 11:10:14

答案(点此获取答案解析)