大神帮我再改一个,作业,谢谢了// recursive.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;double poly(double x,unsigned n){if(n==0){return 1;}if(n==1){poly(x,n

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 13:46:48
大神帮我再改一个,作业,谢谢了// recursive.cpp : Defines the entry point for the console application.//#include
xTj0{ B8jo1v8JjHdCq \lI`=t-eJK6ݲo1Y9rҧ}~U ]Ǔ/ 'ޤMnDozMy$ii;0x m ]`AC7)[(Tt'R[NeוNǐ[ vڱ4HiCPTHl;52v&uNJkdQZRTʄc"P,/R"Lis4i碿5j,$_ 84CLX0&cKB-/r6fKh(\8me)!%AœmEC٠MUb LC%P5$ˮ,G}ݱ+!W>%\b쿻gL:t6XN/G-Lt6J["\8  {?;|xgphyoϛpvwȿFbWr*U JZ 4RMK}8# ;-,bWȈ#b|JXG+5iF(ĩ.8 dd& ^7lăotT!Q&)p[m

大神帮我再改一个,作业,谢谢了// recursive.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;double poly(double x,unsigned n){if(n==0){return 1;}if(n==1){poly(x,n
大神帮我再改一个,作业,谢谢了
// recursive.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
using namespace std;
double poly(double x,unsigned n)
{
if(n==0)
{
return 1;
}
if(n==1)
{
poly(x,n)=x;
return x;
}
if(n>1)
{
return ((2n-1)*x*poly(x,n-1)-(n-1)*poly(x,n-2))/n;
}
int main(int argc, char* argv[])
{
double x;
unsigned n;
cin>>x>>n;
cout

大神帮我再改一个,作业,谢谢了// recursive.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;double poly(double x,unsigned n){if(n==0){return 1;}if(n==1){poly(x,n
改了你几个地方,第一个函数
#include <iostream>
using namespace std;

double poly(double x,unsigned n)
{
if(n==0)
{
return 1;
}
if(n==1)
{
        //x=poly(x,n)
x=poly(x,0);//赋值语句写反了吧,而且原先的递归是死循环,我就改成n=0了
return x;
}
if(n>1)
{
return ((2*n-1)*x*poly(x,n-1)-(n-1)*poly(x,n-2))/n;//这里你的2n.
}
}//你没写
int main(int argc, char* argv[])
{
double x;
unsigned n;
cin>>x>>n;
cout<<poly(x,n)<<endl;
return 0;
}