Advertisement
OMEGAHEAD_MonkoX

Untitled

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