Advertisement
allia

еще треугольник

Nov 13th, 2020 (edited)
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. struct ygol
  8. {
  9.  double a;
  10.  double cos_ygl, sin_ygl, tg_ygl;
  11.  
  12.  ygol (double a)
  13.  {
  14.   cos_ygl = cos(a*3.141592653/180.0);
  15.   sin_ygl = sin(a*3.141592653/180.0);
  16.  
  17.   if (cos_ygl !=0 )
  18.     tg_ygl  = sin_ygl/cos_ygl;
  19.   else tg_ygl = INT32_MAX;
  20.  }
  21. };
  22.  
  23. struct direct
  24. {
  25.  double k = 0, b = 0;
  26.  double parametr = INT32_MAX;
  27. };
  28.  
  29. struct vershina
  30. {
  31.   double x, y;
  32. };
  33.  
  34. direct stright(vershina one, double k)
  35. {
  36.   direct stright;
  37.  
  38.   if (k != INT32_MAX)
  39.     {
  40.       stright.k = k;
  41.       stright.b = one.y - stright.k*one.x;
  42.     }
  43.   else stright.parametr = one.x;
  44.  
  45.   return stright;
  46. }
  47.  
  48. vershina otvet (direct normal_1, direct normal_2)
  49. {
  50.  vershina otvet;
  51.  if (normal_1.parametr == INT32_MAX && normal_2.parametr == INT32_MAX)
  52.  {
  53.    otvet.x = (normal_2.b - normal_1.b)/(normal_1.k - normal_2.k);
  54.    otvet.y = normal_1.k*otvet.x + normal_1.b;
  55.  }
  56.  else if (normal_1.parametr != INT32_MAX)
  57.  {
  58.    otvet.x = normal_1.parametr;
  59.    otvet.y = normal_2.k*otvet.x + normal_2.b;
  60.  }
  61.  else if (normal_2.parametr != INT32_MAX)
  62.  {
  63.    otvet.x = normal_2.parametr;
  64.    otvet.y = normal_1.k*otvet.x + normal_1.b;
  65.  }
  66.  return otvet;
  67. };
  68.  
  69.  int main ()
  70. {
  71.   vershina A, B, C;
  72.   double a, b, c;
  73.   direct AC, BC;
  74.   cin >> B.x >> a >> b;
  75.   c = 180.0 - a - b;
  76.  
  77. A.x = 0;
  78. A.y = 0;
  79.  
  80. B.y = 0;
  81.  
  82.  ygol ygol_A(a);
  83.  ygol ygol_B(180 - b);
  84. // cout << ygol_A.tg_ygl << " " << ygol_B.tg_ygl << endl;
  85. AC = stright(A, ygol_A.tg_ygl);
  86. BC = stright(B, ygol_B.tg_ygl);
  87.  
  88. C = otvet(AC, BC);
  89.  
  90. cout.precision(10);
  91.  cout << fixed << A.x << " " << A.y << endl;
  92.  cout << fixed << B.x << " " << B.y << endl;
  93.  cout << fixed << C.x << " " << C.y << " ";
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement