题解 | #求解立方根#
求解立方根
http://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
方法一:暴力解决
#include <stdio.h>
int main()
{
double num = 0.0;
double temp = 0.0;
double result = 0.0;
scanf("%lf", &num);
if(num >= 0)
{
temp = num;
}
else
{
temp = -num;
}
while(result * result * result < temp)
{
result += 0.01;
}
if(num < 0)
{
result = -result;
}
printf("%.1f", result);
return 0;
}