题解 | #求解立方根#
求解立方根
http://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
//求解立方根,最简单粗暴的解法
include <stdio.h>
int main()
{
double num;
double x=0,y,a;
scanf("%lf",&num);
if(num>0)
a=0.001;
else
a=-0.001;
for(x=0;x<=num||x>=num;x+=a)//不停的试数
{
y=num-xxx;
if(y<0.01&&y>-0.01)
{
printf("%0.1f",x);
break;
}
}
return 0;
}