Advertisement
allia

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

Nov 11th, 2020
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 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()
  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. vector1 sozdanie(vershina one, vershina two)
  27. {
  28.   vector1 a;
  29.   a.x1 = one.x;
  30.   a.y1 = one.y;
  31.   a.x2 = two.x;
  32.   a.y2 = two.y;
  33.   return a;
  34. }
  35.  
  36. double ygol (vector1 one, vector1 two, vector1 three)
  37. {
  38.  double znach;
  39.  znach = (one.length*one.length + two.length*two.length - three.length*three.length)/2*one.length*two.length;
  40.  return znach;
  41. }
  42.  
  43. int main ()
  44. {
  45.   int result = 0;
  46.   vershina A, B, C;
  47.   cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
  48.  
  49.   vector1 *arr = new vector1[3];
  50.  
  51.     arr[0] = sozdanie(A, B);
  52.     arr[1] = sozdanie(B, C);
  53.     arr[2] = sozdanie(A, C);
  54.  
  55.   double znach = arr[0].length;
  56.  
  57.   for (int i = 0; i<3; i++)
  58.     if (znach < arr[i].length)
  59.      {
  60.        znach = arr[i].length;
  61.        result = i;
  62.      }
  63.  
  64.   double itog;
  65.  
  66.   if (result == 0)
  67.    itog = ygol(arr[1], arr[2], arr[0]);
  68.   else if (result == 1)
  69.    itog = ygol(arr[0], arr[2], arr[1]);
  70.   else itog = ygol(arr[1], arr[0], arr[2]);
  71.  
  72.   znach = acos(itog)*180.0/PI;
  73.   cout.precision(6);
  74.   cout << fixed << znach;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement