组卷题库 > 高中信息技术试卷库
试题详情
【加试题】有如下程序段:

  Dim a(1 To 10) As Integer

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

  Dim key As Integer

  i = 1: j = 10: key = Val(Text1.Text)

  Do While i <= j

    m = (i + j) \ 2

    If key < a(m) Then

      j = m - 1

    ElseIf key > a(m) Then

      i = m + 1

    Else

      Do While m > 1

         If a(m - 1) = key Then

          m = m - 1

         Else

          Exit Do

         End If

      Loop

      Exit Do

    End If

  Loop

数组中a(1)到a(10)依次为“1,1,2,3,3,3,3,4,4,4”,若在文本框Text1中输入值3,经上述程序段执行后变量m的值为(  )

A、7
B、6
C、5
D、4
知识点
参考答案
采纳过本试题的试卷
教育网站链接