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