Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n, i;
- double x=0;
- cout<<"Podaj liczbe: ";
- cin>>n;
- double b = M_SQRT2;
- double result = b; //res - konkretne wyniki pomnozone przez siebie
- for(i=2; i<=n; i++)
- {
- b = 2 / sqrt(2+(2*b));
- result *= b;
- }
- result *= 2;
- double wzgl, bezwzgl; //wprowadzenie zmiennej bledu wzgl i bezwzgl
- bezwzgl = abs(M_PI - x);
- wzgl = bezwzgl/(M_PI*100);
- cout<<"blad bezwzgledny "<<bezwzgl<<endl;
- cout<<"blad wzgledny "<<wzgl<<endl;
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement