include stdafx include math include iostream using namespace std doubl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdafx.h"
#include "math.h"
#include <iostream>
using namespace std;
double f (double e)
{
double func=1;
double q =100.0;
while (abs(func-q)>=e)
{q=func;
func=func/2 + 1/func;
}
return func;
}
void main()
{ double e;
cin>>e;
cout<<sqrt(2)<<' '<<f(e);
}