Advertisement
OMEGAHEAD_MonkoX

Untitled

Nov 25th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include<cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. const double pi = 3.141592653589793238462643383279502884197169399375105820974944;
  8.  
  9.  
  10. int main() {
  11. double x, y, angle;
  12. cin >> x >> y;
  13. if (x == 0 && y > 0) {
  14. angle = pi / 2;
  15. cout << fixed << setprecision(5) << angle;
  16. return 0;
  17. }
  18. if (x == 0 && y < 0) {
  19. angle = pi / (-2);
  20. cout << fixed << setprecision(5) << angle;
  21. return 0;
  22. }
  23. if (x == 0 && y == 0) {
  24. cout << fixed << setprecision(5) << 0.0;
  25. return 0;
  26. }
  27. double tg = y / x;
  28. //cout << "tg = " << tg << endl;
  29. double cos = sqrt(1 / (1 + (tg * tg)));
  30. //cout << "cos = " << cos << endl;
  31. angle = acos(cos);
  32. //cout << fixed << setprecision(5) << angle;
  33.  
  34. if (x >= 0 && y >= 0)
  35. {
  36. cout << fixed << setprecision(5) << angle;
  37. return 0;
  38. }
  39. if (x <= 0 && y >= 0)
  40. {
  41. angle = pi - angle;
  42. cout << fixed << setprecision(5) << angle;
  43. return 0;
  44. }
  45. if (x >= 0 && y <= 0)
  46. {
  47. angle = angle * (-1);
  48. cout << fixed << setprecision(5) << angle;
  49. return 0;
  50. }
  51. angle = -pi + angle;
  52. cout << fixed << setprecision(5) << angle;
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement