69,371
社区成员
发帖
与我相关
我的任务
分享
头文件:<math.h>
函数原型:double poly(double x, int degree, double coeffs [] )
函数用途:计算多项式
输入参数:计算 c[n]*x^n+c[n-1]x^n-1+.....+c[1]*x+c[0] 符号^表示幂
输出参数:
返回值:多项式的计算结果
函数例子:
#include <stdio.h>
#include <math.h>
int main(void)
{
double array[] = { -1.0, 5.0, -2.0, 1.0 };
double result;
result = poly(2.0, 3, array);
printf("The polynomial: -x^3 + 5.0*x^2 -2.0*x + 1 at 2.0 is %lf",result);
return 0;
}