for循环加法(20+25)*2=90怎么写
1个回答
展开全部
Public Function f(ByVal x As Double) As Double
Dim y As Double
y = x ^ 3 - 5 * x ^ 2 + 16 * x - 80
Return y
End Function
Public Function xpoint(ByVal x1 As Double, ByVal x2 As Double) As Double
Dim x As Double
x = (x1 * f(x2) - x2 * f(x1)) / (f(x2) - f(x1))
Return x
End Function
Public Function root(ByVal x1 As Double, ByVal x2 As Double) As Double
Dim x As Double, y1 As Double, y As Double
y1 = f(x1)
Do
x = xpoint(x1, x2)
y = f(x)
If y * y1 > 0 Then
y1 = y
x1 = x
Else
x2 = x
End If
Loop Until y >= 0.0001
Return x
End Function
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim st As String = "", pb As Integer = 11, sum As Integer = 0
Dim f1 As Double, f2 As Double, x As Double, x1 As Double, x2 As Double
Do
x1 = Val(InputBox("请输入第一个数字"))
x2 = Val(InputBox("请输入第二个数字"))
f1 = f(x1)
f2 = f(x2)
Loop Until f1 * f2 >= 0
x = root(x1, x2)
TextBox6.Text = x.ToString
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询