小鼠吧 关注:4贴子:3,453
  • 0回复贴,共1

C语言课设1

收藏回复

  • 61.189.60.*
#include <math.h>
float f(float x)
{
float y;
y=((2*x-4)*x+3)*x-6;
return (y);
}
main()
{
float start,end,mid;
scanf("%f,%f",&start,&end);
while(fabs(start-end)>0.01)
   {
   mid=(start+end)/2;
   if(f(mid)*f(start)<=0) end=mid;
    else start=mid;
   }
printf("the root is %f\n",start);
}
 


1楼2009-09-10 08:50回复