回复 2楼 rjsp
求助,#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
double x0,x1,x2,fx0,fx1,fx2,Y,k=0;
x1=0;x2=100;
scanf("%lf",&Y);
fx1=8*x1*x1*x1*x1+7*x1*x1*x1+2*x1*x1+3*x1+6-Y;
fx2=8*x2*x2*x2*x2+7*x2*x2*x2+2*x2*x2+3*x2+6-Y;
do
{
x0=(x1+x2)/2;
fx0=8*x0*x0*x0*x0+7*x0*x0*x0+2*x0*x0+3*x0+6-Y;
if((fx0*fx1)<0)
{
x2=x0;
fx2=fx0;
}
else
{
x1=x0;
fx1=fx0;
}k++;
}while(fabs(fx0)>=0.0001);
if(k==0)
printf("No souition");
else
printf("x= %.4lf",x0);
return 0;
}