public class Main { static double eps = 1e-7; public static void main(String[] args){ double l = 2,r = 3,mid; while(l+eps < r){ mid = (l+r)/2; if(Math.pow(mid,mid) < 10) l = mid; else r = mid; } System.out.printf("%.6f\n",l); } }
本文共 413 字,大约阅读时间需要 1 分钟。
public class Main { static double eps = 1e-7; public static void main(String[] args){ double l = 2,r = 3,mid; while(l+eps < r){ mid = (l+r)/2; if(Math.pow(mid,mid) < 10) l = mid; else r = mid; } System.out.printf("%.6f\n",l); } }
转载于:https://www.cnblogs.com/tudou1179006580/p/6670528.html