注意 当 x 为负数时 和 当 x 的绝对值小于 1 时
#include <bits/stdc++.h>
using namespace std;
const double N = 1e-7;
int main()
{
double x;
cin >> x;
int flag = 0;
if(x < 0){
flag ++;
x = abs(x);
}
double i = 0, j;
if(x < 1) j = 1;
else j = x;
while(abs(j - i) > N)
{
double mid = (i + j) / 2;
if(mid * mid * mid >= x) j = mid;
else i = mid;
}
if(flag == 0) printf("%.6lf", j);
else printf("-%.6lf", j);
return 0;}