Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cmath>
- #include <iomanip>
- using namespace std;
- int main() {
- double x, y, angle;
- cin >> x >> y;
- if (x == 0 && y > 0) {
- angle = 3.1415926535 / 2;
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x == 0 && y < 0) {
- angle = 3.1415926535 / (-2);
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x == 0 && y == 0) {
- cout << 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 = 3.1415926535 - angle;
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- if (x >= 0 && y <= 0)
- {
- angle = angle * (-1);
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
- angle = -3.1415926535 + angle;
- cout << fixed << setprecision(5) << angle;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement