Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- double a, b, c;
- double a1, b1, c1;
- double x, y, x0, y0, x1, y1, x2, y2, x3, y3;
- cin >> x0 >> y0 >> x1 >> y1;
- cin >> x2 >> y2 >> x3 >> y3;
- a = y0 - y1;
- b = x1 - x0;
- c = x0 * y1 - x1 * y0;
- a1 = y2 - y3;
- b1 = x3 - x2;
- c1 = x2 * y3 - x3 * y2;
- x = (b * c1 - b1 * c)/(a * b1 - a1 * b);
- y = (a1 * c - a * c1)/(a * b1 - a1 * b);
- if (x0 == x2 && y0 == y2 && x1 == x3 && y1 == y3){
- cout << 2;
- return 0;
- }
- if (((x1 - x0) / (y1 - y0)) == ((x3 - x2)/(y3 - y2))){ cout << 0;
- return 0;}
- else cout << 1 << " " << x << " " << y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement