
C语言怎么样用二分法求方程的解
2个回答
展开全部
x1,x2请输入-10,10
#include <stdio.h>
#include <math.h>
void main()
{
float x0,x1,x2,f0,f1,f2;
do
{
printf("please enter x1 & x2:\n");
scanf("%f,%f",&x1,&x2);
f1=((2*x1-4)*x1+3)*x1-6;
f2=((2*x2-4)*x2+3)*x2-6;
}
while ((f1*f2)>0);
do
{
x0=(x1+x2)/2;
f0=((2*x0-4)*x0+3)*x0-6;
if ((f0*f1)<0)
{
x2=x0;
f2=f0;
}
else
{
x1=x0;
f1=f0;
}
}
while(fabs(f0)>=1e-5);
printf("the root of equation is :%f\n",x0);
}
#include <stdio.h>
#include <math.h>
void main()
{
float x0,x1,x2,f0,f1,f2;
do
{
printf("please enter x1 & x2:\n");
scanf("%f,%f",&x1,&x2);
f1=((2*x1-4)*x1+3)*x1-6;
f2=((2*x2-4)*x2+3)*x2-6;
}
while ((f1*f2)>0);
do
{
x0=(x1+x2)/2;
f0=((2*x0-4)*x0+3)*x0-6;
if ((f0*f1)<0)
{
x2=x0;
f2=f0;
}
else
{
x1=x0;
f1=f0;
}
}
while(fabs(f0)>=1e-5);
printf("the root of equation is :%f\n",x0);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?

2025-07-02 广告
是的。传统上,对于符合要求的内毒素检测,最终用户必须从标准内毒素库存瓶中构建至少一式两份三点标准曲线;必须有重复的阴性控制;每个样品和PPC必须一式两份。有了Sievers Eclipse内毒素检测仪,这些步骤可以通过使用预嵌入的内毒素标准...
点击进入详情页
本回答由Sievers分析仪提供
展开全部
x1,x2请输入-10,10
#include
<stdio.h>
#include
<math.h>
void
main()
{
float
x0,x1,x2,f0,f1,f2;
do
{
printf("please
enter
x1
&
x2:\n");
scanf("%f,%f",&x1,&x2);
f1=((2*x1-4)*x1+3)*x1-6;
f2=((2*x2-4)*x2+3)*x2-6;
}
while
((f1*f2)>0);
do
{
x0=(x1+x2)/2;
f0=((2*x0-4)*x0+3)*x0-6;
if
((f0*f1)<0)
{
x2=x0;
f2=f0;
}
else
{
x1=x0;
f1=f0;
}
}
while(fabs(f0)>=1e-5);
printf("the
root
of
equation
is
:%f\n",x0);
}
#include
<stdio.h>
#include
<math.h>
void
main()
{
float
x0,x1,x2,f0,f1,f2;
do
{
printf("please
enter
x1
&
x2:\n");
scanf("%f,%f",&x1,&x2);
f1=((2*x1-4)*x1+3)*x1-6;
f2=((2*x2-4)*x2+3)*x2-6;
}
while
((f1*f2)>0);
do
{
x0=(x1+x2)/2;
f0=((2*x0-4)*x0+3)*x0-6;
if
((f0*f1)<0)
{
x2=x0;
f2=f0;
}
else
{
x1=x0;
f1=f0;
}
}
while(fabs(f0)>=1e-5);
printf("the
root
of
equation
is
:%f\n",x0);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询