4.9 ҽط󷽳f(x)=x3η-5x2η+16x-80=0ĸ
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double f(double);                 // 
double xpoint(double, double);     //
double root(double, double);       //

int main( )
{ double x1,x2,f1,f2,x;
 do
  {cout<<input x1,x2;
   cin>>x1>>x2;
   f1=f(x1);
   f2=f(x2);
  } while(f1*f2>=0);
 x=root(x1,x2);
 cout<<setiosflags(iosfixed)<<setprecision(7);  
//ָ7λС
 cout<<A root of equation is <<x<<endl;
 return 0;
}

double f(double x)              //fʵf(x)
{double y;
 y=x*x*x-5*x*x+16*x-80;
 return y;
}

double xpoint(double x1, double x2)       //xpointύ
{double y;
 y=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));    //xpointеf
 return y;
}

double root(double x1, double  x2)       //rootƸ
{double x,y,y1;
 y1=f(x1);
 do
  {x=xpoint(x1,x2);             //rootеxpoint
   y=f(x);                      //rootеf
   if (y*y1>0)
    {y1=y;
     x1=x;
    }
   else
x2=x;
  }while(fabs(y)>=0.00001);
 return x;
}
