#include<stdio.h> #include<math.h> int main() { float x,y,a; scanf("%f",&a); x=a/2; x=(x+a/x)/2; y=(x+a/x)/2; while(fabs(y-x)>0.00001) { x=(x+a/x)/2; y=(x+a/x)/2; } printf("%.3f\n",y); return 0; }
Double click to view unformatted code.