zadasd_zest2/asdzes2zad3heron/main.c
Michał Krzysztof Feiler 47722313e1
zad3
2019-01-24 03:36:18 +01:00

34 lines
449 B
C

#include <math.h>
#include <stdio.h>
static long long unsigned c;
static long double eps;
static long double x;
static long long unsigned n;
int next()
{
long double p = x;
x = (p + (c / p)) / 2;
n++;
return fabsl(x - p) >= eps;
}
void print()
{
printf("x_%llu=%Lf, ", n, x);
}
int main()
{
scanf("%llu %Lf", &c, &eps);
x = c;
n = 0;
print();
while (next())
print();
print();
return 0;
}