#include<stdio.h> #include <string.h> #include <math.h> void main() { double x,b=1.0,a; scanf("%lf",&x); while(fabs(b-a)>=pow(0.1,5)){ a=b; b=(a+x/a)/2; } printf("%.3lf",b); return 0; }
Double click to view unformatted code.