Dim cj(8, 2) As Single
Private Sub Form_Click()
Dim i As Integer, k As Integer
Dim pro As String
For i = 1 To 8
pro = " 请输入第" + Str(i) + "号运动员的成绩:"
cj(i, 1) = InputBox(pro)
cj(i, 2) = i
Next i
Call sort(cj)
Call output(cj)
End Sub
Private Sub sort(cj() As Single)
Dim temp_cj As Single
Dim i As Integer, j As Integer
For i = 1 To 7
Min = i
For j = i + 1 To 8
If cj(j, 1) < cj(Min, 1) Then
Min = j
End If
Next j
temp_cj = cj(i, 1)
t = cj(i, 2)
cj(i, 1) = cj(Min, 1)
cj(i, 2) = cj(Min, 2)
cj(Min, 1) = temp_cj
cj(Min, 2) = t
Next i
End Sub
Private Sub output(cj() As Single)
Dim j As Integer, p As Integer
p = 1: j = 1
For i = 1 To UBound(cj, 1) - 1
Print "第 " & j & "名是" & cj(i, 2) & "运动员,成绩为 " & cj(i, 1)
If cj(i + 1, 1) <> cj(i, 1) Then j = j + p: p = 1 Else p = p + 1
Next i
Print "第 " & j & "名是" & cj(i, 2) & "运动员,成绩为 " & cj(i, 1)
End Sub