组卷题库 > 高中信息技术试卷库
试题详情
某次考试的流程为先笔试再面试,笔试成绩达到面试资格线的可以入围参加面试。入围面试的资格线根据计划录取人数的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

知识点
参考答案
采纳过本试题的试卷
教育网站链接