分享到:
>prec>>a>>b; while(fabs(a-b)>=prec){ c=(a+b)/2; if(f(a)*f(c)">
发表于 2022-11-16 17:02:12 楼主 | |
#include #include #include using namespace std; double x,y; double prec; double f(double x){ int y=pow(2,x)+3*x-7; return y; } int main() { int a,b,c; cin>>prec>>a>>b; while(fabs(a-b)>=prec){ c=(a+b)/2; if(f(a)*f(c)<0){ b=c; }else{ if(f(c)==0){ a=c; break; }else{ a=c; } } x=a; } cout<<x<<endl;
return 0; } |
|
楼主热贴
个性签名:无
|
针对ZOL星空(中国)您有任何使用问题和建议 您可以 联系星空(中国)管理员 、 查看帮助 或 给我提意见