#include<stdio.h> #include<math.h> int main() { double x2,a,x1; scanf("%lf",&a); x2=a/2; while(fabs(x2-x1)>=1e-5) { x1=x2; x2=(x2+a/x2)/2; } printf("%.3lf",x2); return 0; }
Double click to view unformatted code.