首页 > 编程语言 > 详细

【c语言】厄密多项式--用递归实现

时间:2015-04-05 18:54:11      阅读:214      评论:0      收藏:0      [点我收藏+]
/* 厄密多项式是这样定义的:
      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 <stdio.h>

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时候的例子

技术分享

技术分享

技术分享

【c语言】厄密多项式--用递归实现

原文:http://blog.csdn.net/zhaoyaqian552/article/details/44889419

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!