SHARE
TWEET

Untitled

a guest Sep 15th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double a, b, c;
  8. double a1, b1, c1;
  9. double x, y, x0, y0, x1, y1, x2, y2, x3, y3;
  10. cin >> x0 >> y0 >> x1 >> y1;
  11. cin >> x2 >> y2 >> x3 >> y3;
  12. a = y0 - y1;
  13. b = x1 - x0;
  14. c = x0 * y1 - x1 * y0;
  15. a1 = y2 - y3;
  16. b1 = x3 - x2;
  17. c1 = x2 * y3 - x3 * y2;
  18. x = (b * c1 - b1 * c)/(a * b1 - a1 * b);
  19. y = (a1 * c - a * c1)/(a * b1 - a1 * b);
  20. if (x0 == x2 && y0 == y2 && x1 == x3 && y1 == y3){
  21.     cout << 2;
  22.     return 0;
  23. }
  24. if (((x1 - x0) / (y1 - y0)) == ((x3 - x2)/(y3 - y2))){ cout << 0;
  25. return 0;}
  26. else cout << 1 << " " << x << " " << y;
  27.  
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top