Advertisement
allia

треугольник

Nov 13th, 2020 (edited)
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. struct otrezok
  9. {
  10.   double x1, y1, x2, y2, x, y;
  11.   double length;
  12. };
  13.  
  14. struct vershina
  15. {
  16.   double x, y;
  17. };
  18. double cos_ygla (double ygol)
  19. {
  20.   double znach;
  21.   znach = cos(ygol*3.141592653/180.0);
  22.   return znach;
  23. }
  24. vershina teorema (double cos_ygol, otrezok a, otrezok b)
  25. {
  26.   vershina znach;
  27.   znach.x = b.length*cos_ygol;
  28.   double n = a.length*a.length + b.length*b.length - 2*znach.x*a.length;
  29.   znach.y = sqrt(n - (znach.x - a.length)*(znach.x - a.length));
  30.   return znach;
  31. }
  32. int main ()
  33. {
  34.   otrezok AB, BC;
  35.   double ygol_B;
  36.   cin >> AB.length >> BC.length >> ygol_B;
  37.   vershina B;
  38.  
  39.   B.x = 0;
  40.   B.y = 0;
  41.  
  42.   AB.x = AB.length;
  43.   AB.y = 0;
  44.  
  45.   vershina C;
  46.  
  47.   double cos_B = cos_ygla(ygol_B);
  48.   C = teorema(cos_B, AB, BC);
  49.  
  50.   cout.precision(10);
  51.   cout << fixed << B.x << " " << B.y << endl;
  52.   cout << fixed << AB.x << " " << AB.y << endl;
  53.   cout << fixed << C.x << " " << C.y << " ";
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement