Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. struct tchk {
  7. int x,y;
  8. };
  9.  
  10. int main()
  11. {
  12. tchk t1,t2,t3,t4;
  13. int a1,b1,c1,a2,b2,c2;
  14. cin >> t1.x >> t1.y >> t2.x >> t2.y;
  15. cin >> t3.x >> t3.y >> t4.x >> t4.y;
  16. a1=t2.y-t1.y;
  17. b1=t1.x-t2.x;
  18. c1=t1.y*t2.x-t2.y*t1.x;
  19. a2=t4.y-t3.y;
  20. b2=t3.x-t4.x;
  21. c2=t3.y*t4.x-t4.y*t3.x;
  22. if (a1*b2==a2*b1 && a1*c2==a2*c1 && b1*c2==b2*c1) {
  23. cout << 2;
  24. return 0;
  25. } else if (a1*b2!=a2*b1) {
  26. double x,y;
  27. x=double((b1*c2)-(b2*c1))/double((a1*b2)-(a2*b1));
  28. y=double((a2*c1)-(a1*c2))/double((a1*b2)-(a2*b1));
  29. cout << 1 << endl;
  30. cout << setprecision(9) << fixed;
  31. cout << x << " " << y;
  32. } else {
  33. cout << 0;
  34. }
  35. /*
  36. else if (a1*b2==a2*b1 && a1*c2!=a2*c1 && b1*c2!=b2*c1) {
  37. cout << 0;
  38. return 0;
  39. } else {
  40. double x,y;
  41. x=double((b1*c2)-(b2*c1))/double((a1*b2)-(a2*b1));
  42. y=double((a2*c1)-(a1*c2))/double((a1*b2)-(a2*b1));
  43. cout << 1 << endl;
  44. cout << setprecision(9) << fixed;
  45. cout << x << " " << y;
  46. }
  47. */
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement