数的三次方根
#include<iostream> #include<math.h> #include<cstdio> using namespace std; int main() { double t; cin>>t; double l=-10000,r=10000,m; while(r-l>1e-8) { m=(l+r)/2.0; if((m*m*m)>=t) { r=m; } else l=m; } printf("%.6lf",l); }
#include<iostream> #include<math.h> #include<cstdio> using namespace std; int main() { double t; cin>>t; double l=-10000,r=10000,m; while(r-l>1e-8) { m=(l+r)/2.0; if((m*m*m)>=t) { r=m; } else l=m; } printf("%.6lf",l); }
相关推荐