用递归算法求n阶勒让得多项式的值,递归公式为:
p(n)(x) = 1 (n=0)
x (n=1)
((2n-1)*x-p(n-1)(x)-(n-1)*p(n-2)(x))/n (n>=1)
#include "stdafx.h"
#include <iostream>
using namespace std;
int x;
int p(int n)
{
int a;
本文介绍了如何使用C++编程实现递归算法来计算n阶勒让得多项式的值。通过递归公式 `(2n-1)*x - p(n-1)(x) - (n-1)*p(n-2)(x) / n`,当n等于0或1时,分别返回1和x。给出的代码示例中定义了一个名为`p`的递归函数,用于根据输入的n和x值计算多项式,并在主函数 `_tmain` 中读取用户输入并输出结果。
用递归算法求n阶勒让得多项式的值,递归公式为:
p(n)(x) = 1 (n=0)
x (n=1)
((2n-1)*x-p(n-1)(x)-(n-1)*p(n-2)(x))/n (n>=1)
#include "stdafx.h"
#include <iostream>
using namespace std;
int x;
int p(int n)
{
int a;
1935
845

被折叠的 条评论
为什么被折叠?