求浮点数 n的三次方根
#include <iostream> using namespace std; double n; double BF (double x) { double l = -100, r = 100; while (r - l > 1e-8) { double mid = (l + r) / 2; if (mid * mid * mid < x) l = mid; else r = mid; } return l; } int main() { double x; cin >> x; printf("%.6lf\n", BF(x)); return 0; }
标签:BF,return,double,mid,方根,三次,100 From: https://www.cnblogs.com/leetothemoon/p/16939676.html