Re: [VBA ] bisection 的 recursive

看板Visual_Basic作者 (Luke)時間15年前 (2010/10/19 17:45), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
還是自問自答@@,又改了一下程式碼,這樣做好像比較符合了 只是把Function rebicon改了一下: ============================== Function rebicon(n As Integer, xl As Double, xr As Double) As Double Dim xm As Double xm = (xl + xr) / 2# If (infun(xl) = 0) Then rebicon = xl ElseIf (infun(xm) = 0) Then rebicon = xm ElseIf (infun(xr) = 0) Then rebicon = xr ElseIf (n > 1) Then If (infun(xl) * infun(xm) < 0) Then xr = xm n = n - 1 ElseIf (infun(xm) * infun(xr) < 0) Then xl = xm n = n - 1 End If MsgBox "xl = " & xl & " xm = " & (xl + xr) / 2# & " xr = " & xr rebicon = rebicon(n, xl, xr) End If End Function -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.184.60.219 ※ 編輯: tp6b123 來自: 111.184.60.219 (10/19 19:32)
文章代碼(AID): #1ClMZN-A (Visual_Basic)
文章代碼(AID): #1ClMZN-A (Visual_Basic)