Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cmath>
- #include <iomanip>
- using namespace std;
- const double pi = 3.141592653589793238462643383279502884197169399375105820974944;
- int main() {
- double x, y, angle;
- cin >> x >> y;
- if (x == 0 && y > 0) {
- angle = pi / 2;
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x == 0 && y < 0) {
- angle = pi / (-2);
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x == 0 && y == 0) {
- cout << fixed << setprecision(5) << 0.0;
- return 0;
- }
- double tg = y / x;
- //cout << "tg = " << tg << endl;
- double cos = sqrt(1 / (1 + (tg * tg)));
- //cout << "cos = " << cos << endl;
- angle = acos(cos);
- //cout << fixed << setprecision(5) << angle;
- if (x >= 0 && y >= 0)
- {
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x <= 0 && y >= 0)
- {
- angle = pi - angle;
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x >= 0 && y <= 0)
- {
- angle = angle * (-1);
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- angle = -pi + angle;
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement