学习当中出现的问题,我怎么也解决不了
#include#include
int main(void)
{
double x0,x1,eps,m,n,a,f();
printf("please input x[0]=\n");
scanf("%lf",&x[0]);
printf("please input eps=\n");
scanf("%lf",&eps);
printf("please input m=\n");
scanf("%lf",&m);
n=0;
do
{
x[1]=f(x[0]);
if(fabs(x[1]-x[0])>m)
{
printf("迭代失败,程序终止\n");
return 0;
}
a=x[0];
x[0]=x[1];
n++;
}
while((x[0]-a)>eps);
printf("x0=%lf,n=%lf",x0,n);
return 0;
}
double f(double x)
{
double y;
y=0.5*log(4-x);
return y ;
}
/*方程的近似解法-迭代法,简单迭代法,求方程x=1/2*ln(x-4)的解,可是每次输入只能得到x0的值,我想要x0,x1,x2,x3,x4,x5,.............的值全出来,怎么解决呢?*