试题

试题 试卷

logo

题型:单选题 题类:模拟题 难易度:困难

浙江省普通高校招生信息技术选考模拟卷(五)

【加试题】某对分査找算法的VB程序段如下: 数组元素a(1)到a(7)的值依次为“24,35,38,41,45,69,78”。若该程序段执行后,文本框Text1中显示的内容可能是(  )

i = 1: j = 7: s = ""

key = Int(Rnd * 100)

Do While i <= j

   m = (i + j) \ 2

   If key = a(m) Then

      s = s + "M": Exit Do    'Exit Do 表示退出循环

   ElseIf key < a(m) Then

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

   Else

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

   End If

Loop

Text1.Text = s

A、RL B、LMR C、RLR D、LRLM
举一反三
【加试题】某省学生信息技术学习平台使用情况数据存储在数据库中,利用VB编写一个程序,实现功能:输入一个积分的范围,显示该范围内的学生编号和对应的积分。程序运行界面如图所示:

程序代码如下,为实现上述功能,请在画线处填写合适的代码。

Dim bh(10 000)As String        ‘存储学生编号

Dim jf(10 000)As Integer       ‘存储学生获得的积分值

Dim n As Integer               ‘存储学生总人数

Function Search(x As Integer)As Integer

    Search=0

    i=1:j=n:flag=True

    Do While i<=j And flag=True

      m=Int((i+i)/2)

      If x=jf(m) Then

         flag=False

             ①  

      Elself    ②     Then

        i=m+1

      Else

        j=m-1

      EndIf

    Loop

End Function

Private Sub Form_Load()

    ‘从数据库中读取学生编号和积分,分别存储到bh数组和jf数组中,并按积分值从小到大排序,显示在列表框List1中

End Sub

Private Sub Command1_Click()

    Dim Top As Integer,Bottom As Integer,Topxb As Integer,Bottomxb

As Integer

    List2.Clear

    Top=Val(Text1.Text)

    Bottom=Val(Text2.Text)

    If Top>Bottom Then t=Top:Top=Bottom:Bottom=t

    If Top>jf(n)Or Bottom<jf(1)Then Exit Sub

    Do While Search(Top)=0

      Top=Top+1

    Loop

    Do While Search(Bottom)=0

      Bottom=Bottom-1

    Loop

    Topxb=Search(Top)

    Do While jf(Topxb)=jf(Topxb-1)And Topxb>l

      Topxb=Topxb-1

    Loop

    Bottomxb=Search(Bottom)

    Do While jf(Bottomxb)=jf(Bottomxb+1)And Bottomxb<n

      Bottomxb=Bottomxb+1

    Loop

    For i=    ③    

       List2.AddItem bh(i)&"    "&jf(i)

    Next i

End Sub

①{#blank#}1{#/blank#} ②{#blank#}2{#/blank#} ③{#blank#}3{#/blank#} 

返回首页

试题篮