当前位置: 高中信息技术 / 单选题
  • 1. (2019高三上·浙江月考) 【加试题】有如下程序段:

      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

微信扫码预览、分享更方便