6个评委为4位歌手打分,分数介于1-100之间。去掉一个最高分,一个最低分,求出每位选手的最后得分。将4位歌手得分从高到低排列输出,同时输出该选手的编号。
如:歌手395分
歌手 187分
歌手 480分
歌手 270分
Option Explicit: Option Base 1
Private Type candidates
number As Integer
score As Single
End Type
Dim a(4) As candidates
Private Sub Command1_Click()
Dim max As Integer, min As Integer, i As Integer, j As Integer, t As Single
For i = 1 To 4
a(i).number = i
max = 60: min = 99
For j = 1 To 6
t = Int(Rnd * 40 60)
If tmax Then max = t
If tmin Then min = t
a(i).score = a(i).score t
Next
a(i).score = (a(i).score - max - min) / 4
Next
End Sub
Private Sub Command2_Click()
Dim t As candidates, i As Integer, j As Integer
For i = 1 To 4
For j = 1 To 4 - i
If a(j).scorea(j 1).score Then
t = a(j): a(j) = a(j 1): a(j 1) = t
End If
Next
Next
For i = 1 To 4
Picture1.Print a(i).number, a(i).score
Next
End Sub
Private Sub Form_Load()
Picture1.FontSize = 16
End Sub
|