学习递归后的第一个程序问题
程序代码:#include <stdio.h>
#include <math.h>
void bisect(double a,double b);
void find_root(double c,double d);
double f(double g);
double epslion;
int main ()
{
double x1,
x2,
epslion;
printf("ENTER THE INTERVAL ENDPOINTS>\n");
scanf("%lf%lf",&x1,&x2);
printf("enter the tolerance");
scanf("%lf",&epslion);
bisect(x1,x2);
}
void bisect(double a,double b)
{
double f1,
f2;
f1 = f(a);
f2 = f(b);
if (f1*f2>0)
printf("the root is not here\n");
else if(f1*f2==0)
{
if(f1==0)
printf("one root is%.3f",a);
if(f2==0)
printf("one root is%.3f",b);
}
else
{
find_root(a,b);
}
}
void find_root(double c,double d)
{
double e,
m;
if (fabs(d - c)> epslion)
{
e = (c+d)/2;
m = f(e);
}
else
printf("the root is01 at [%.3f,%.3f]\n",c,d);/*从不显示*/
if (m==0)
printf("the root is02 %.3f\n",e);
else if(f(c)*m<0)
{
find_root(c,e);
}
else if(f(d)*m<0)
{
find_root(e,d);
}
}
double f(double g)
{
return(pow(g,2)-6*g+4);
}
感觉设置的epsilon没用上。。。。。请大家帮我分析分析我这个程序,优化一下









