C++ 代码
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double n;
cin >> n;
double l = -100, r = 1e5;//r不能选n,如果n为负数,三次方根将不在,[l,r]区间内
while(r - l > 1e-7)
{
double mid = (r + l) / 2 ;
if(pow(mid, 3) >= n)r = mid;
else l = mid;
}
printf("%.6lf", l);
return 0;
}