English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

題目:下表為某地星期一至星期四的時段一、時段二與時段三的氣溫:

星期一 星期二 星期三 星期四
----------------------------------
時段一 18.2 17.3 15.0 13.4
時段二 23.8 25.1 20.6 17.8
時段三 20.6 21.5 18.4 15.7


請將上表的內容直接於程式中以陣列初值方式設定,並依序完成下列各題:
(a)印出陣列內容。
(b)每日的平均溫度。
(c)時段一、時段二與時段三的平均氣溫。
(d)溫度最高的日子與時段。
(e)溫度最低的日子與時段。

2005-12-12 07:49:19 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

你會把它改成DEV檔嗎?
我學的是這種檔案@@...
不過很高興你替我解答謝謝~

2005-12-12 10:43:54 · update #1

1 個解答

Private Sub Command1_Click()
Dim A(4, 5) As String, I As Integer, J As Integer, ArA, ArB, ArC, ArD, ArE
Dim Max As Double, Min As Double, T As Double, V As Double, strMax As String, strMin As String
ArA = Array(Space(16), "星期一", "星期二", "星期三", "星期四", "平均溫")
ArB = Array("時段一", "18.2", "17.3", "15.0", "13.4", "0"): ArC = Array("時段二", "23.8", "25.1", "20.6", "17.8", "0")
ArD = Array("時段三", "20.6", "21.5", "18.4", "15.7", "0"): ArE = Array("平均溫", "0", "0", "0", "0", "0")
For I = 0 To 5
A(0, I) = ArA(I): A(1, I) = ArB(I)
A(2, I) = ArC(I): A(3, I) = ArD(I): A(4, I) = ArE(I)
Next
Max = 0: Min = 100
For I = 1 To 4
T = 0: V = 0
For J = 1 To 4
T = T + Val(A(I, J)): V = V + Val(A(J, I))
If I < 4 Then
If A(I, J) > Max Then Max = Val(A(I, J)): strMax = "最高溫度 : " & A(0, J) & "的" & A(I, 0)
If A(I, J) < Min Then Min = Val(A(I, J)): strMin = "最低溫度 : " & A(0, J) & "的" & A(I, 0)
End If
Next
A(I, 5) = Format(T / 4, "0.0"): A(4, I) = Format(V / 3, "0.0")
Next: A(4, 5) = ""
For I = 0 To 4
For J = 0 To 5
Do Until Me.TextWidth("星期一 ") <= Me.TextWidth(A(I, J))
If IsNumeric(A(I, J)) Then
A(I, J) = " " & A(I, J)
Else
A(I, J) = A(I, J) & " "
End If
Loop: Print A(I, J);
Next: Print
Next
Print: Print strMax: Print strMin
End Sub

2005-12-12 10:36:03 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers