📄 平分法.cpp
字号:
/*平分法*/
#include<iostream.h>
#include<math.h>
double F(double x)
{
double f;
f=pow(x,2)-x+2;
return f;
}
double Fderivate(double x)
{
double f;
f=x-1;
return f;
}
int main()
{
double a=-1,b=3;
double e=0.01;
double f1,x;
int c;
step1: c=0.5*(b+a);
if(b-a<e)
goto step4;
else
goto step3;
step3: f1=Fderivate(c);
if(f1==0)
goto step4;
else if(f1<0)
{a=c;goto step1;}
else
{b=c;goto step1;}
step4: x=c;
cout<<"x*="<<x;
cout<<"press input enter key to end"<<'\n';
cin.get();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -