下列函数过程用于计算代数多项式a1+a2x+a3x2+…anxn-1的值,请将其补充完整Private Function f(a() As Single,x As Single,n As Integer) As SingleEnd Function
2019-05-07
下列函数过程用于计算代数多项式a1+a2x+a3x2+…anxn-1的值,请将其补充完整
Private Function f(a() As Single,x As Single,n As Integer) As Single
End Function
优质解答
Private Function f(a() As Single, x As Single, n As Integer) As Single
f = 0
Dim i As Integer
Dim y As Single
For i = 0 To UBound(a) - 1
y = 1
For j = 1 To i
If i > 0 Then
y = y * x
End If
Next j
f = f + a(i) * y
Next i
End Function
Private Function f(a() As Single, x As Single, n As Integer) As Single
f = 0
Dim i As Integer
Dim y As Single
For i = 0 To UBound(a) - 1
y = 1
For j = 1 To i
If i > 0 Then
y = y * x
End If
Next j
f = f + a(i) * y
Next i
End Function