Advertisement
allia

углы треугольника?

Nov 11th, 2020
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. #define PI 3.14159265  
  8.  
  9. class vector1
  10. {
  11.   public:
  12.   double x1, y1, x2, y2;
  13.   double length;
  14.  
  15.   vector1(double x1, double y1, double x2, double y2)
  16.  {
  17.    length = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
  18.  }
  19. };
  20.  
  21. struct vershina
  22. {
  23.   double x, y;
  24. };
  25.  
  26. double sozdanie(vershina one, vershina two)
  27. {
  28.   vector1 a(one.x, one.y, two.x, two.y);
  29.   double znach = a.length;
  30.   return znach;
  31. }
  32.  
  33. double ygol (double one, double two, double three)
  34. {
  35.  double znach;
  36.  znach = (one*one + two*two - three*three)/(2*one*two);
  37.  return znach;
  38. }
  39.  
  40. int main ()
  41. {
  42.   vershina A, B, C;
  43.   cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
  44.  
  45.   double *arr = new double[3];
  46.  
  47.     arr[0] = sozdanie(A, B);
  48.     arr[1] = sozdanie(B, C);
  49.     arr[2] = sozdanie(A, C);
  50.  
  51.   double *result = new double[3];
  52.  
  53.   result[0] = acos(ygol(arr[1], arr[2], arr[0]))*180.0/PI;
  54.   result[1] = acos(ygol(arr[0], arr[2], arr[1]))*180.0/PI;
  55.   result[2] = 180 - result[0] - result[1];
  56.  
  57.   double znach = result[0];
  58.  
  59.   cout.precision(10);
  60.   for (int i = 0; i < 3; i++)
  61.   {
  62.     if (znach < result[i])
  63.      znach = result[i];
  64.   }
  65.  
  66.   cout << fixed << znach;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement