Option Base 1
Private Sub Form_Activate()
Dim score(10, 5) As Single
score(1, 1) = 60: score(1, 2) = 87: score(1, 3) = 37
score(2, 1) = 75: score(2, 2) = 86: score(2, 3) = 42
score(3, 1) = 56: score(3, 2) = 50: score(3, 3) = 51
score(4, 1) = 44: score(4, 2) = 90: score(4, 3) = 61
score(5, 1) = 48: score(5, 2) = 30: score(5, 3) = 48
score(6, 1) = 99: score(6, 2) = 87: score(6, 3) = 75
score(7, 1) = 77: score(7, 2) = 62: score(7, 3) = 48
score(8, 1) = 20: score(8, 2) = 81: score(8, 3) = 87
score(9, 1) = 66: score(9, 2) = 25: score(9, 3) = 52
score(10, 1) = 81: score(10, 2) = 87: score(10, 3) = 98
FontSize = 10
loopcount = 0
Print "學生成績", "計概", "數學", "英文", "平均"
Print "==============================================================="
g = Array("阿宏", "城城", "阿豹", "阿慕", "東西", "阿斌", "海豚", "蟑螂", "大雄", "洪爺")
For i = 1 To 10
Print g(i) & "";
score(i, 4) = (score(i, 1) + score(i, 2) + score(i, 3)) / 3
For j = 1 To 4
Print Format(score(i, j), " 00.00");
Next j
Print
Next i
Dim x As Single
Dim k As Integer
Dim y As String
For i = 1 To 10
For j = 1 To 10
If score(i, 4) > score(j, 4) Then
For k = 1 To 4
x = score(i, k)
score(i, k) = score(j, k)
score(j, k) = x
Next k
y = g(i)
g(i) = g(j)
g(j) = y
End If
Next j
Next i
Print
Print "排行榜"
Print "學生", "計概", "數學", "英文", "平均",
Print
Print "============================================================================"
For i = 1 To 10
Print g(i) & "",
score(i, 4) = (score(i, 1) + score(i, 2) + score(i, 3)) / 3
For j = 1 To 4
Print Format(score(i, j), "00.00"),
Next j
Print
Next i
End Sub
老師說還要排名次...可是做到這邊就卡住了..不知道要怎嚜排名次..大大可否交依下
2006-11-02 05:35:24 · 1 個解答 · 發問者 呆呆的 1 in 電腦與網際網路 ➔ 程式設計
'排名方式:如有2個第1名就沒第2名,直接跳第3名.Option Base 1Private Sub Form_Activate() Dim Score(10, 4) As Single, I As Integer, J As Integer Score(1, 1) = 60: Score(1, 2) = 87: Score(1, 3) = 37 Score(2, 1) = 75: Score(2, 2) = 86: Score(2, 3) = 42 Score(3, 1) = 56: Score(3, 2) = 50: Score(3, 3) = 51 Score(4, 1) = 44: Score(4, 2) = 90: Score(4, 3) = 61 Score(5, 1) = 48: Score(5, 2) = 30: Score(5, 3) = 48 Score(6, 1) = 99: Score(6, 2) = 87: Score(6, 3) = 75 Score(7, 1) = 77: Score(7, 2) = 62: Score(7, 3) = 48 Score(8, 1) = 20: Score(8, 2) = 81: Score(8, 3) = 87 Score(9, 1) = 66: Score(9, 2) = 25: Score(9, 3) = 52 Score(10, 1) = 81: Score(10, 2) = 87: Score(10, 3) = 98 FontSize = 10 Print "學生成績", "計概", "數學", "英文", "平均" Print String(60, "=") G = Array("阿宏", "城城", "阿豹", "阿慕", "東西", "阿斌", "海豚", "蟑螂", "大雄", "洪爺") For I = 1 To 10 Print G(I) & "", Score(I, 4) = (Score(I, 1) + Score(I, 2) + Score(I, 3)) / 3 For J = 1 To 4 Print Format(Score(I, J), " 00.00"), Next Print Next I Dim X As Single, K As Integer, Y As String For I = 1 To 10 For J = 1 To 10 If Score(I, 4) > Score(J, 4) Then For K = 1 To 4 X = Score(I, K) Score(I, K) = Score(J, K) Score(J, K) = X Next Y = G(I) G(I) = G(J) G(J) = Y End If Next Next Print Print "排行榜" Print "名次", "學生", "計概", "數學", "英文", "平均", Print Print String(74, "=") Dim N%, T! T = Score(1, 4): N = 1 For I = 1 To 10 If T <> Score(I, 4) Then Print CStr(I),: N = I: T = Score(I, 4) Else Print CStr(N), End If Print G(I) & "", For J = 1 To 4 Print Format(Score(I, J), "00.00"), Next Print NextEnd Sub
2006-11-02 08:55:13 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋