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) Input #1, r, N
arr = r * r * 3.14 arr = Int(arr + 0.5) Print #2, arr
Private Sub Form_Load() Me.Hide Dim ans% Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, r, n ans = r * r * 3.14 Print #2, ans Loop Close Close End End Sub
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) Input #1, r, N
A = 360 / N '一角幾度 B = A * (3.14 / 180) '度轉弧度
'公式為0.5 * r^2 * sin(弧度) arr = (0.5 * r * r * Sin(B)) * N arr = Int(arr + 0.5) Print #2, arr
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) Input #1, m, n Print #2, A1(m, n) Loop Close Close End End Sub
Function A1(r, b) ik = (360 / b) * (3.14 / 180) ok = (180 - (360 / b)) / 2 c = (r ^ 2 + r ^ 2 - 2 * r * r * Cos(ik)) ^ 0.5 s = (r + r + c) / 2 ans = ((s * (s - r) * (s - r) * (s - c)) ^ 0.5) * b A1 = Int(((ans + 0.5) * 100) / 100) End Function
想很久想不出來去查資料
回覆刪除有個證明式
http://www.ananedu.com/a/2/5/page10255.htm
窮 竭 法
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)
Input #1, r, N
arr = r * r * 3.14
arr = Int(arr + 0.5)
Print #2, arr
Loop
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Dim ans%
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, r, n
ans = r * r * 3.14
Print #2, ans
Loop
Close
Close
End
End Sub
我記得以前國小還國中教圓的時候
那時候好像說 3.14 是把圓切成很多個三角形
最後算出來的
arro,佑好,
回覆刪除如果輸入的是
10 4
你們的程式,都錯了吧。
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)
Input #1, r, N
A = 360 / N '一角幾度
B = A * (3.14 / 180) '度轉弧度
'公式為0.5 * r^2 * sin(弧度)
arr = (0.5 * r * r * Sin(B)) * N
arr = Int(arr + 0.5)
Print #2, arr
Loop
Close #2
Close #1
End
End Sub
in.txt
2 2000
10 3000
10 4
out.txt
13
314
200
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)
Input #1, m, n
Print #2, A1(m, n)
Loop
Close
Close
End
End Sub
Function A1(r, b)
ik = (360 / b) * (3.14 / 180)
ok = (180 - (360 / b)) / 2
c = (r ^ 2 + r ^ 2 - 2 * r * r * Cos(ik)) ^ 0.5
s = (r + r + c) / 2
ans = ((s * (s - r) * (s - r) * (s - c)) ^ 0.5) * b
A1 = Int(((ans + 0.5) * 100) / 100)
End Function
我先解他的底 然後再去用海龍公式求面積