Const n=640 '参加统测总学生数
Const nc =16 '班级数
Dim class(1 To n) As Integer, sname(1 To n)As String, score(1 To n) As Integer
Dim b( To nc) As Integer '存储每个班级的参加统测人数
Dim c(1 To nc) As Integer
Dim d(1 To n)As Integer
Private Sub Form_Load()
'本过程读取每个参加统测学生的班级序号、姓名和统测成绩分别存储在数组class,sname和 score中并在List1中显示,代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer
For i = 1 To nc
b(i) = 0
Next i
For i = 1 To n '统计每个班级统测人数
Next i
k = 1
For i = 1 To nc
c(i) = k
k = k + b(i)
Next i
For i = 1 To n
k = class (i)
c(k) = c(k) + 1
Next i
For i = 1 To nc '对各班级按统测成绩进行排序
Call px(),c(i)-1))
Next i
For i = 1 To n
List2.AddItem " " & class(d(i)) & " "& sname (d(i)) & " " & score(d(i))
Next i
End Sub
Private Sub px(head As Integer, tail As Integer)
Dim i As Integer, j As Integer, t As Integer
For i = head To tail - 1
For j = tail To i + 1 Step -1
If Then
t = d(j): d(j) = d(j - 1): d(j - 1) = t
End If
Next j
Next i
End Sub