Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, i;
  8. double x=0;
  9. cout<<"Podaj liczbe: ";
  10. cin>>n;
  11. double b = M_SQRT2;
  12. double result = b; //res - konkretne wyniki pomnozone przez siebie
  13. for(i=2; i<=n; i++)
  14. {
  15. b = 2 / sqrt(2+(2*b));
  16. result *= b;
  17. }
  18. result *= 2;
  19. double wzgl, bezwzgl; //wprowadzenie zmiennej bledu wzgl i bezwzgl
  20.  
  21. bezwzgl = abs(M_PI - x);
  22. wzgl = bezwzgl/(M_PI*100);
  23. cout<<"blad bezwzgledny "<<bezwzgl<<endl;
  24. cout<<"blad wzgledny "<<wzgl<<endl;
  25. }
  26. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement