6 2 多項式求值

2021-09-10 07:51:07 字數 723 閱讀 4101

6-2 多項式求值 (15 分)

本題要求實現乙個函式,計算階數為n,係數為a[0]...a[n]的多項式f(x)=∑​i=0​n​​(a[i]×x​i​​) 在x點的值。

double f( int n, double a, double x );
其中n是多項式的階數,a中儲存係數,x是給定點。函式須返回多項式f(x)的值。

#include #define maxn 10

double f( int n, double a, double x );

int main()

/* 你的**將被嵌在這裡 */

2 1.1

1 2.5 -38.7

-43.1
#include #define maxn 10

double f( int n, double a, double x );

int main()

double f ( int n, double a[ ], double x )

return sum;

}

6 2 多項式求值(15分)

採用遞迴的方式解決 答案如下 double f int n,double a,double x 題目如下 本題要求實現乙個函式,計算階數為n,係數為a 0 a n 的多項式f x i 0 n a i x i 在x點的值。函式介面定義 double f int n,double a,double x ...

6 2 多項式求值 15分

本題要求實現乙個函式,計算階數為n,係數為a 0 a n 的多項式f x i 0 n a i x i 在x點的值。函式介面定義 doublef int n,double a,double x 其中n是多項式的階數,a中儲存係數,x是給定點。函式須返回多項式f x 的值。裁判測試程式樣例 includ...

6 2 多項式求值 15分

本題要求實現乙個函式,計算階數為n,係數為a 0 a n 的多項式 的值。函式介面定義 doublef int n,double a,double x 其中n是多項式的階數,a中儲存係數,x是給定點。函式須返回多項式f x 的值。裁判測試程式樣例 include define maxn 10 dou...