如何計算名次高低:如果總分同分,以國文、英文、數學之高為優先?
以下使我的程式...
Dim temp() As String, A(), B(), C(), D(), E()
Open App.Path & \"/score.txt\" For Input As #1
Print \"座號\", \"國文\", \"英文\", \"數學\", \"總分\"
Do
i = i + 1: ReDim Preserve temp(i): ReDim Preserve A(i): ReDim Preserve B(i): ReDim Preserve C(i): ReDim Preserve D(i): ReDim Preserve E(i)
Line Input #1, temp(i)
If i <> 1 Then
x = Split(temp(i), \" \")
Print x(0), x(1), x(2), x(3),
A(i) = x(0): B(i) = x(1): C(i) = x(2): D(i) = x(3)
E(i) = Val(B(i)) + Val(C(i)) + Val(D(i))
Print E(i)
End If
Loop Until EOF(1)
Dim f()
ReDim f(i)
For j = 1 To i - 1
For k = j + 1 To i
If E(j) < E(k) Then
t1 = A(j): t2 = B(j): t3 = C(j): t4 = D(j): t5 = E(j)
A(j) = A(k): B(j) = B(k): C(j) = C(k): D(j) = D(k): E(j) = E(k)
A(k) = t1: B(k) = t2: C(k) = t3: D(k) = t4: E(k) = t5
End If
Next k
Next j
Cls
For j = 1 To i
Print A(j), E(j)
Next j
2006-05-27 04:39:25 · 3 個解答 · 發問者 天使 4 in 電腦與網際網路 ➔ 程式設計
'假設每科成績最高分沒超過3位數,且最低分為0分及無小數Private Sub Command1_Click()Dim T() As String, X() As String, A() As Integer, B() As String, I%, J%Open App.Path & "/score.txt" For Input As #1Print "座號", "國文", "英文", "數學", "總分"Do Until EOF(1) ReDim Preserve T(I), A(I), B(I) Line Input #1, T(I) If I > 0 Then X = Split(T(I)) Print X(0), For J = 1 To 3 A(I) = A(I) + Val(X(J)) '把各科成績組成字串,便於當總分相同時再比對此字串 B(I) = B(I) & Format(X(J), "000") Print X(J), Next Print A(I) T(I) = X(0) End If I = I + 1LoopClose #1Dim Tmp%, S$, K$For I = 1 To UBound(A) For J = I To UBound(A) If (A(I) < A(J)) Or (A(I) = A(J) And B(I) < B(J)) Then Tmp = A(I): A(I) = A(J): A(J) = Tmp S = T(I): T(I) = T(J): T(J) = S K = B(I): B(I) = B(J): B(J) = K End If NextNextPrintFor I = 1 To UBound(A) Print T(I), A(I)NextEnd Sub
2006-05-27 11:03:02 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
台中網路行銷首選-。。眾智數位科技網路行銷。。
你知道嗎? 網站訪問流量的第一來源竟是搜尋引擎之網站排名SEO!!企業該如何做好部落格行銷呢?知識家行銷呢?網站排名呢?網路行銷呢?全方位的網路行銷能帶來哪些好處呢?如何在茫茫人海中對你有印象?對你的產品有印象?熟悉你的品牌?要如何在琳瑯滿目的商品購買你?決定買你?喜歡持續購買你呢?要如何在眾網路平台中看見你?釘睛於你呢?品牌忠誠於你呢?網路無所不在,看不見你的訊息都難!眾智數位科技具有網路行銷十多年的經驗!歡迎您隨時來電詢問~。。眾智數位科技有限公司。。SEO_line_App行銷(眾智數位)
2014-05-30 08:57:31 · answer #2 · answered by Anonymous · 0⤊ 0⤋
總分同分,以國文、英文、數學之高為優先?? 這應該是題目要定好的吧~
如果題目沒寫,就照題目上寫的順序「國英數」就好啦@@
2006-06-06 21:07:08 · answer #3 · answered by 文澳寶 4 · 0⤊ 0⤋