试题 试卷
题型:单选题 题类:常考题 难易度:普通
浙江省高中信息技术 查找算法及程序实现同步练习
n=0
i=1
j=6
key=val(Text1 text)
f=False
Do While i<=j And Not f
m=(i+j+1)\2
n=n+1
If key=d(m) Then
f=True
ElseIf key>d(m) Then
j=m-1
Else
i=m+1
End if
Loop
数组元素d(1)到d(6)的值依次为“87,72,53,41,29,18”,若该程段运行结束后,n的值为2,则key的值是 ( )
a(1) = 1
For i = 2 To 12
a(i) = a(i - 1) + Int(Rnd * 2) + 1
Next i
Key = Val(Text1.Text)
i = 1: j = 12: cnt = 1: flag = False
Do While i <= j And flag = False
cnt = cnt + 1
m = (i + j + 1) \ 2
If a(m) = Key Then
flag = True
ElseIf Key > a(m) Then
i = m + 1
j = m - 1
End If
程序运行后,下列说法正确的是( )
n=0: i= 1:j-6
key = Val(Text1.Tex1)
Do While i<=j
m=(i+j)\2
If key = d(m) Then Exit Do
If key> d(m) Then j=m-1 Else i=m+ 1
d(1)到d(6)的值依次为"88,77,53,47,39,23",并且输入key值为40,下列说法正确的是( )
Key=int(Rnd*7)+2
L=1: R=8
Do While L<=R
m=(L+R)\2
if Key=a(m) Then
Exit Do
Elseif a(m)<Key Then
L=m+1
R=m-1
n=n-1
print Str(n)
则程序运行后,输出的结果不可能是( )
试题篮