当前位置: 高中信息技术 / 单选题
  • 1. (2021高三上·浙江开学考) 某对分查找算法的 VB 程序如下:

    Private Sub Command1_Click()

        Dim d(1 To 10) As Integer, i As Integer, j As Integer

        Dim m As Integer, key As Integer, s As String

        key = Int(Rnd( ) * 50) *2+ 1

        s = "": i = 1: j = 10

        Do While i <= j

            m = (i + j) \ 2

            If key = d(m) Then Exit Do

            If key < d(m) Then

                j = m - 1: s = s + "L"

            Else

                i = m + 1: s = s + "R"

            End If

        Loop

        Label1.Caption = s

    End Sub

    若数组d(1)至d(10)的值依次为"11,13,20,48,51,67,70,73,80,91",若执行后 Label1 上显示2个“L”和1个“R”或2个“R”和1个“L”,则key的可取值个数为(   )

    A . 6 B . 13 C . 17 D . 22

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