试题

试题 试卷

logo

题型:单选题 题类:常考题 难易度:普通

浙江省金华市江南中学2020届高三下学期信息技术4月初测试卷

数组b是一个有重复数据的递增数组,现把前面n个元素整体移动到最后形成如“7,8,9,10,1,2,3,4”的排列形式。下列程序实现如下功能:输入一个数,利用对分查找算法在数组b中查找,返回查找结果在Label2输出,若有多个相同数据,则返回最左侧数据的位置。

Dim b(1 To 20) As Integer

Private Sub Command1_Click()

 Dim i As Integer, j As Integer, m As Integer

 i = 1: j = 20

 Key = Val(Text1.Text)

 Do While   (1)   

  m = (i + j + 1) \ 2

  If b(i) < b(m) Then

   If    (2)   Then 

    j = m - 1

   Else

    i = m + 1

  ElseIf Key = b(m) Then

   Exit Do

  Else

   If Key > b(m) And Key <= b(j) Then

    i = m + 1

   Else

    j = m - 1

  End If

 Loop

 If   (3)   Then

  Label2.Caption = "数组中无此数"

 Else

  Do While m > 0

   If Key = b(m) Then m = m - 1 Else Exit Do

  Loop

  Label2.Caption = "此数在第" + Str(m + 1) + "个位置"

 End If

End Sub

(1)、(2)(3)处可选语句为:

①i > j

②i <= j

③Key < b(m) And Key >= b(i)

④Key> b(m) And Key <=b(j)

则(1)(2)(3)处的语句依次是(  )

A、①③② B、②④① C、②③① D、①④②
返回首页

试题篮