Aleksandr_Grigoryev

HW 7.b

Dec 6th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void Intersection(int a1, int b1, int c1, int a2, int b2, int c2, int& xv,int &yv)
  4. {
  5.     if (((a1 == 0) && (b1 == 0)) || ((a2 == 0)&&(b2 == 0)))
  6.         cout << "there is no such direct";
  7.     else if ((a1 / a2) == (b1 / b2)&&((a1 / a2) == (c1 / c2)))
  8.         cout << "   Straight lines coincide";
  9.     else if ((a1 / a2) == (b1 / b2)&&((b1 / b2) != (c1 / c2)))
  10.         cout << "parallel";
  11.     else if ((a1 / a2) != (b1 / b2))
  12.     {
  13.         cout << "intersect";
  14.         xv = (-1)*(c1*b2 - c2*b1) / (a1*b2 - a2*b1);
  15.         yv = (-1)*(c2*a1 - c1*a2) / (a1*b2 - a2*b1);
  16.     }
  17. }
  18.     int main ()
  19.     {  
  20.         int a1,a2,b1,b2,c1,c2,c3,a3,b3,vx1,vy1,vx2,vy2,vx3,vy3;
  21.         double s;
  22.         cin >> a1 >> b1 >> c1;
  23.     cin >> a2 >> b2 >> c2;
  24.     cin >> a3 >> b3 >> c3;
  25.      Intersection(a1, b1, c1,a2,b2, c2,vx1,vy1);
  26.      Intersection(a1, b1, c1, a3, b3, c3,vx2,vy2);
  27.      Intersection(a2, b2, c2, a3, b3, c3,vx3,vy3);
  28.      s = 1 / 2 * ((vx1 - vx3)*(vy2 - vy3) - (vy1 - vy3)*(vx2 - vx3));
  29.      cout << "s=" << s;
  30.  
  31.      system("pause");
  32.      return 0;
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment