Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Intersection(int a1, int b1, int c1, int a2, int b2, int c2, int& xv,int &yv)
- {
- if (((a1 == 0) && (b1 == 0)) || ((a2 == 0)&&(b2 == 0)))
- cout << "there is no such direct";
- else if ((a1 / a2) == (b1 / b2)&&((a1 / a2) == (c1 / c2)))
- cout << " Straight lines coincide";
- else if ((a1 / a2) == (b1 / b2)&&((b1 / b2) != (c1 / c2)))
- cout << "parallel";
- else if ((a1 / a2) != (b1 / b2))
- {
- cout << "intersect";
- xv = (-1)*(c1*b2 - c2*b1) / (a1*b2 - a2*b1);
- yv = (-1)*(c2*a1 - c1*a2) / (a1*b2 - a2*b1);
- }
- }
- int main ()
- {
- int a1,a2,b1,b2,c1,c2,c3,a3,b3,vx1,vy1,vx2,vy2,vx3,vy3;
- double s;
- cin >> a1 >> b1 >> c1;
- cin >> a2 >> b2 >> c2;
- cin >> a3 >> b3 >> c3;
- Intersection(a1, b1, c1,a2,b2, c2,vx1,vy1);
- Intersection(a1, b1, c1, a3, b3, c3,vx2,vy2);
- Intersection(a2, b2, c2, a3, b3, c3,vx3,vy3);
- s = 1 / 2 * ((vx1 - vx3)*(vy2 - vy3) - (vy1 - vy3)*(vx2 - vx3));
- cout << "s=" << s;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment