Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdio>
  4. #include <vector>
  5. #include <string>
  6. #include <algorithm>
  7. #include <cmath>
  8.  
  9. using namespace std;
  10.  
  11. const double EPS = 1E-6;
  12.  
  13. int n = 2;
  14. vector<double> x(n);
  15.  
  16. int main()
  17. {
  18. //variant 3
  19. // x - cos y = 3
  20. // cos ( x - 1) + y = 0.5
  21. x[0] = 3;
  22. x[1] = 3.5;
  23.  
  24. double last1 = 100000;
  25. double last2 = 100000;
  26. while ((fabs(last1 - fabs(x[0])) > EPS) || (fabs(last2 - fabs(x[1])) > EPS))
  27. {
  28. last1 = fabs(x[0]);
  29. last2 = fabs(x[1]);
  30.  
  31. double xx = x[0];
  32. double yy = x[1];
  33.  
  34. x[0] -= xx - cos (yy) - 3.0;
  35. x[1] -= cos(xx - 1.0) + yy - 0.5;
  36. }
  37.  
  38.  
  39. cout << fixed << setprecision(8) << x[0] << endl << x[1];
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement