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