函数调用
#include"stdio.h"#include"math.h"
float f(float x)
{
return ((x-5)*x+16)*x-80;
}
float xpoint(float x1,float x2)
{
return (x1*f(x1)-x2*f(x2))/(f(x2)-f(x1));
}
float root(float x1,float x2)
{
int i;
float x,y,y1;
y1=f(x1);
do
{
x=xpoint(x1,x2)
y=f(x);
if(y*y1>0)
{
y=y1;
x=x1;
}
else {x2=x}
}while(fabs(y)>0.00001)
return x;
}
main()
{
float x1,x2,y1,y2,x;
do
{
printf("input x1,x2")
scanf("%f%f",&x1,&x2);
y1=f(x1);
y2=f(x2);
}while(y1*y2>0);
x=root(x1,x2);
printf("aroot is %f\n",x);
}
帮忙看看哪出错了