f(x)是二次函数,f(0)=-1,f(x+1)=f(x)-2x+2,求f(x)

来源:百度知道 编辑:UC知道 时间:2024/06/16 05:49:50
要完整的过程

f(x+1)-f(x)=-2x+2
f(x)-f(x-1)=-2(x-1)+2
f(x+1)-2f(x)+f(x-1)=2

y^3-2y^2+y-2=0

y=2 or y=i

后面不会了,都忘了,我觉得这是个函数方程题而不是编程题,不然他告诉你是二次函数干什么

# include"stdio.h"
int fun(int x)
{
int f;
if(x>0)
f=fun(x-1)-2*(x-1)+2;
if(x==0)
return -1;
x--;
return f;
}
void main()
{
int x,f;
printf("Please insert the value of X:");
scanf("%d",&x);
f=fun(x);
printf("f(%d)=%d\n",x,f);
}
你看看这个程序怎么样

这么简单还是自己做吧,考试没人帮你