定义eps的时候用都double不用int
代码
#include<iostream>
#include<cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const double eps =1e-8;
int main()
{
double n;
cin>>n;
double l=-1e6,r=1e6;
while(r-l>eps)
{
double mid=(l+r)/2;
if(mid*mid*mid<n)l=mid;
else r=mid;
}
printf("%.6lf",l);
return 0;
}