数的三次方根
没啥说的,别写成l=-x,r=x就行
Java样例
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double x = sc.nextFloat();
double l=-10000, r=10000;
while(r-l>1e-7) {
double mid = (l+r)/2;
if(mid*mid*mid>=x) r=mid;
else l=mid;
}
System.out.printf("%.6f",l);
}
}