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