/* 厄密多项式是这样定义的:
n <= 0时,h(n(x)) = 1;
n = 1时,h(n(x)) = 2*x;
n >= 2时,h(n(x)) = 2*x*(h(n-1)(x)) - 2*(n-1)*(h(n-2)(x));
编写递归函数,函数应该和下面的函数原型匹配:
int hermite(int n, int x)*/
#include
int hermite(int n, int x)
{
int h = 0;
if( n <= 0 )
h = 1;
else if( n == 1 )
h = 2 * x;
else
h = 2 * x * hermite( n - 1, x ) - 2 * ( n - 1 ) * hermite( n - 2, x );
return h;
}
int main()
{
printf("%d\n",hermite(3,2));
return 0;
}
下边截图分别是 n=0,n=1,n=3,x=2时候的例子