当前位置: 高中信息技术 / 单选题
  • 1. (2020高三下·宁波开学考) 有如下VB 程序段:

    Private Sub Command1_Click()

        Dim a(1 to 10) As Integer

        Dim i As Integer, j As Integer, Key As Integer, c As Integer, m As Integer

        Dim flag As boolean

        flag = True: c = 0

        i = 1: j = 10

        Key = Int(Rnd() * 17) + 8

        Do While i <= j And flag = True

            c = c + 1

            m = (i + j) \ 2

            If Key = a(m) Then

                flag = False

            ElseIf Key > a(m) Then

                j = m - 1

            Else

                i = m + 1

            End If

        Loop

    End sub

    数组元素a(1)到a(10)的值依次为50、45、40、35、27、24、15、7、5、3,程序运行后变量c的值可能是:(     )

    A . 1 或2 B . 2 或3 C . 3 或4 D . 4 或5

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