#include <stdio.h> #include <string.h> #include <math.h> #define N 100 int main() { float x; float a = 0, b; scanf("%f", &x); b = 1.0; while (fabs(b - a) > 0.00001) { a = b; b = (a + x / a) / 2; } printf("%.3f", b); } |
Double click to view unformatted code.