当前位置: 高中信息技术 / 单选题
  • 1. (2020高三上·衢州月考) 有如下VB程序段:

    a(1) = 11 : a(2) = 14 : a(3) = 23 : a(4) = 23 : a(5) = 30 : a(6) = 42

    key = Val(Text1.Text)

    L = 1 : R = 6 : x = 0

    Randomize

    Do while L <= R

        mid = Int(Rnd() * (R-L+1))+ L

        If a(mid) = key Then

            Exit Do

        ElseIf a(mid) > key Then

            R = mid - 1

            x = x - 1

        Else

            L = mid + 1

            x = x + 1

        End If

    Loop

    If L <= R Then

        Label1.Caption = "查找成功," + "位置为" + str(mid)

    Else

        Label1.Caption = "查找失败"

    End If

    该程序执行后,在文本框Text1中输入23,则x的值不可能是(  )

    A . -3 B . -2 C . 1 D . 2

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