试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:困难

浙江省义乌市群星外国语学校2017届高三上学期期中考试信息技术试题

合唱队列是按队员的身高进行排列,形成中间高两边有序降低的队形;例如有六个队员“己、戊、丁、丙、乙和甲”的身高依次由小到大,则排列后的顺序为“戊、丙、甲、乙、丁、己”。小李用VB编写模拟“合唱队列”程序,功能如下:在文本框Text1中输入各队员身高,输入结束并回车,则输入的各队员身高分别存入数组a中;单击“合唱队列”按钮Command1,对数组a的元素进行有序排列后,将各元素存入数组C中形成合唱队列,并将结果显示在文本框Text2中。程序运行界面如图所示: 甲、乙、丙、丁、戊和己

    实现上述功能的VB程序如下:       

(1)、如果输入各队员身高为“190,191,194,179,166”,则合唱队列的结果为
(2)、实现上述功能的VB程序如下,请在划线处填入合适代码。

Dim a(1 To 20) As Integer

Dim n As Integer

Private Sub Text1_KeyPress(KeyAscii As Integer)

'将输入各队员身高分别存入数组a中,队员个数为n,代码略!

End Sub

Private Sub Command1_Click()

Dim c(1 To 20) As Integer

Dim right As Integer, left As Integer, i As Integer

For i = 1 To n – 1          

    For j =1 To n-i

        If      ①      Then          

            t = (j): a(j) = a(j + 1): a(j + 1) = t

        End If

    Next j

Next i

‘下列程序段实现数组C的合唱队列

m = (1 + n) \ 2

left = m: right = m

c(m) = a(n)      

i = 2

Do While i <= n

    If  i  Mod 2 = 0  Then

        right = right + 1

        c(right) = a(n-i+1)

    Else

                 ②      

        c(left) = a(n-i+1)

    End If

    i = i + 1

Loop

s =      ③     

For i = 2 To n

    s = s + "," + Str(c(i))

Next i

Text2.Text = s

End Sub

 ② ③ 

举一反三
某次考试的流程为先笔试再面试,笔试成绩达到面试资格线的可以入围参加面试。入围面试的资格线根据计划录取人数的200%划定,即如果考试最终录取x人,则第2*x名选手的笔试分数为面试资格分数线(该分若有同分者可一同参加面试)。现在编写VB程序功能如下:自动读取数据库中考生考号和笔试成绩,依次存储在数组kh(i)、cj (i)中,并显示在Listl列表框中。

用户从Text1中输入计划人数,单击“入围划线”按钮Command1,面试分数线显示在文本框Text2 中,入围面试最终人数显示在 Text3中,进入面试考生的考号和笔试成绩显示在List2列表框中,如果成绩相同,则按考号从小到大的顺序显示。程序界面如图所示。

Dim kh(1 To 500) As String, cj(1 To 500) As Integer

Dim n As Integer ′参加考试总人数

Private Sub Form_Load()

Dim conn As New ADODB.Conncction

Dim rs As New ADODB.Recordset

conn.ConnectionString = “Provider=Microsoft.ACE.OLEDB.12.0;datasource=”+App.Path + ”\BSCJ.accdb”

conn.Open

Set rs.ActiveConnection = conn

rs.Open “select * FROM scoreinfo”

′本过程其他代码略

End Sub

Private Sub Commandl_click()

Dim m As Integer, i As Integer, j As Integer

Dim t1 As Integer, t2 As String, flag As Boolean

For i = 1 To n - 1

  For j = 1 To

    If cj(i) < cj(j) Then

      t1 = cj(i): cj(i) = cj(j): cj(j) = t1

      t2 = kh(i): kh(i) = kh(j): kh(j) = t2

    EleIf      ①      Then

      t2 = kh(i): kh(i) = kh(j): kh(j) = t2

    End If

  Next j

Next i

m =     ②     

If m <= n Then

  i = m

  flag = Flase

  Do While i < n And Not flag
    If cj(i) = cj(i + 1) Then

      i = i + 1

 Else

             ③     

 End If
  Loop

  Text2.Text = Str(cj(m))

  Text3.Text = Str(i)

  For j = 1 To i

    List2.Addltem kh(j) + “ ” + Str(cj(j))

  Next j

Else

  Text2.Text = “面试人数超过了总人数”

End If

End Sub

返回首页

试题篮