?? duiban.cpp
字號:
#include<iostream.h>
#include<math.h>
#include<iomanip.h>
int sign(long double s)
{
if(s>=0)
return 1;
else
return -1;
}
long double ab(long double s)
{
if(s<0)
s=-s;
return s;
}
void main()
{
long double a=0.0,b=1.0,c=0.0000000000001,u=1.0,x,w;
int k=0;
do{
x=(a+b)/2;
w=cos(2*x)-9.0/4*x;
cout<<k<<"\t"<<setprecision(10)<<x<<"\t"<<setprecision(10)<<w<<endl;
k++;
if(sign(w)!=sign(u))
b=x;
else{
a=x;
u=w;
}
}while(ab(w)>=c);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -