## C++勒让德多项式求解

#include
#include
using namespace std;
double polya(double x, int n)
{
if (n == 0)return 1;
else
{
if (n == 1)return x;
return ((2 * n - 1)*polya(x, n - 1) - (n - 1)*polya(x, n - 2)) / n;
}
}
int main()
{
double x;
int n;
while (cin >> x >> n)
{
cout <<fixed<<setprecision(4)<< polya(x, n) << endl;
}

}

猜你喜欢

转载自blog.csdn.net/m0_45864023/article/details/103448979