Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     double x[3];
  9.     double y[3];
  10.     const double PI = acos(-1.0);
  11.  
  12.     for (int i = 0; i < 3; ++i)
  13.         cin >> x[i] >> y[i];
  14.  
  15.     double medPointX, medPointY;
  16.     medPointX = x[1] + ((x[0] + x[2]) / 2 - x[1]) * 2 / 3;
  17.     medPointY = y[1] + ((y[0] + y[2]) / 2 - y[1]) * 2 / 3;
  18.  
  19.  
  20.     for (int i = 0; i < 2; ++i)
  21.     {
  22.         for (int j = i + 1; j < 3; ++j)
  23.         {
  24.             double fVectorX = x[i] - medPointX,
  25.                 fVectorY = y[i] - medPointY,
  26.                 sVectorX = x[j] - medPointX,
  27.                 sVectorY = y[j] - medPointY;
  28.  
  29.  
  30.             double scalar = fVectorX * sVectorX + fVectorY * sVectorY;
  31.             double a_len = sqrt(fVectorX * fVectorX + fVectorY * fVectorY);
  32.             double b_len = sqrt(sVectorX * sVectorX + sVectorY * sVectorY);
  33.  
  34.             double alpha = acos(scalar / (a_len*b_len))*180/PI;
  35.  
  36.             cout.precision(2);
  37.             cout << fixed << alpha << endl;
  38.         }
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement