Dim k As Single Dim q As Single Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Until EOF(1) k = 0 Input #1, x For i = 1 To x Input #1, y k = k + y Next i k = k / x
If Int(k) = k Then Print #2, k Else Print #2, Int(k) + 1 & ","; Int(k) End If Loop Close #2 Close #1 End Sub BY阿揚
Dim ans As Integer, Q As Integer, T As Double Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) su = 0 Input #1, Q For i = 1 To Q Input #1, x su = su + x Next i T = su / Q If Int(T) <> T Then ans = Int(T) Print #2, "A=" & ans & "、" & ans + 1 Else ans = Int(T) Print #2, "A=" & ans End If Loop Close #2 Close #1 End End Sub
Dim k As Single
回覆刪除Dim q As Single
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do Until EOF(1)
k = 0
Input #1, x
For i = 1 To x
Input #1, y
k = k + y
Next i
k = k / x
If Int(k) = k Then
Print #2, k
Else
Print #2, Int(k) + 1 & ","; Int(k)
End If
Loop
Close #2
Close #1
End Sub
BY阿揚
Dim ans As Integer, Q As Integer, T As Double
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
su = 0
Input #1, Q
For i = 1 To Q
Input #1, x
su = su + x
Next i
T = su / Q
If Int(T) <> T Then
ans = Int(T)
Print #2, "A=" & ans & "、" & ans + 1
Else
ans = Int(T)
Print #2, "A=" & ans
End If
Loop
Close #2
Close #1
End
End Sub
BY 小白
就是平均數而已嗎?
回覆刪除還是要靠數學功力啊。