题解 | #求解立方根#
求解立方根
https://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
#include <iostream>
using namespace std;
int main() {
double a;
cin >> a;
double l = -20, r = 20;
while (r - l > 1e-3) {
double mid = (l + r) / 2;
if (mid * mid * mid >= a)
r = mid;
else
l = mid;
}
printf("%.1lf\n", l);
return 0;
}
上海得物信息集团有限公司公司福利 1227人发布