Advertisement
allia

квадрат 2

Nov 16th, 2020 (edited)
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. struct otrezok
  7. {
  8.   public:
  9.   double x1, y1, x2, y2, x, y;
  10.   double length;
  11. };
  12.  
  13. struct vershina
  14. {
  15.   double x, y;
  16. };
  17.  
  18. otrezok vector (vershina head, vershina seredina)
  19. {
  20.  otrezok time;
  21.  
  22.    time.x1 = head.x;
  23.    time.y1 = head.y;
  24.    time.x2 = seredina.x;
  25.    time.y2 = seredina.y;
  26.  
  27.    time.x = time.x2 - time.x1;
  28.    time.y = time.y2 - time.y1;
  29.  
  30.  double znach = time.x;
  31.  
  32.  time. x = time.y;
  33.  
  34.  if (znach != 0)
  35.  time.y = -znach;
  36.  else time.y = znach;
  37.  //cout << time.x << " " << time.y << endl;
  38.  time.x1 = time.x2 - time.x;
  39.  time.y1 = time.y2 - time.y;
  40.  return time;
  41. }
  42.  
  43. int main ()
  44. {
  45.   vershina A, C;
  46.   cin >> A.x >> A.y >> C.x >> C.y;
  47.   otrezok AC, DB;
  48.  
  49.   vershina seredina_AC;
  50.  
  51.   seredina_AC.x = (A.x + C.x)/2;
  52.   seredina_AC.y = (A.y + C.y)/2;
  53.  
  54.   AC = vector (A, seredina_AC);
  55.   DB = vector (C, seredina_AC);
  56.  
  57.  
  58.   cout << AC.x1 << " " << AC.y1 << endl;
  59.   cout << DB.x1 << " " << DB.y1 << endl;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement