Advertisement
Tolyamba

CF_TR5_A

Jun 13th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. // CF_TR5_A
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #define M_PI 3.1415926535897932384626433832795
  4. #include <iostream>
  5. #include <stdio.h>
  6. #include <fstream>
  7. #include <math.h>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     long double x, y;
  14.     ifstream file_in("angle1.in");
  15.     file_in >> x >> y;
  16.     file_in.close();
  17.    
  18.     long double ang = 0;
  19.     if ((x > 0) && (y >= 0)) ang = atan2(y, x);
  20.     if ((x > 0) && (y < 0)) ang = atan2(y, x) + 2 * M_PI;
  21.     if (x < 0) ang = atan2(y, x) + M_PI;
  22.     if ((x == 0) && (y > 0)) ang = M_PI / 2;
  23.     if ((x == 0) && (y < 0)) ang = 3 * M_PI / 2;
  24.    
  25.     ofstream file_out("angle1.out");
  26.     file_out << ang;
  27.     file_out.close();
  28.  
  29.     //system("pause");
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement