VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3615
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5445
   LinkTopic       =   "Form1"
   ScaleHeight     =   3615
   ScaleWidth      =   5445
   StartUpPosition =   3  '窗口缺省
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Dim s1 As stud, sARRAY() As StudOrder, s2 As StudOrder     '记录类型变量,读写单位
 Private Sub Form_Click()
    Open "c:\stud.dat" For Random As #1 Len = Len(s1)
    Open "c:\stud_order.dat" For Random As #2 Len = Len(s2)
    n = LOF(1) / Len(s1)      '确定文件中的记录数
    ReDim sARRAY(1 To n)
    i = 0
    aver = 0
    Do While Not EOF(1)       ' 读取随机文件，存入排序数组中，求总平均分
       Get #1, , s1
       i = i + 1
       aver = aver + s1.summark
       sARRAY(i).name = s1.name
       sARRAY(i).summark = s1.summark
     Loop
     aver = aver / n
     For i = 1 To n - 1               ' 按总分高到低排序
       For j = i + 1 To n
         If sARRAY(j).summark > sARRAY(j - 1).summark Then
           s2 = sARRAY(j)
           sARRAY(j) = sARRAY(j - 1)
           sARRAY(j - 1) = s2
         End If
       Next j
     Next i
     For i = 1 To n                 ' 将高于平均分的考生成绩、姓名、名次存入另一个随机文件
       If sARRAY(i).summark > aver Then
        sARRAY(i).order = i
        Put #2, i, sARRAY(i)
        Print sARRAY(i).order, sARRAY(i).name, sARRAY(i).summark
       End If
     Next i
End Sub
