Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double x1, y1, x2, y2, x3, y3, x4, y4, a1, b1, c1, a2, b2, c2, x, y;
  6.  
  7.  
  8. double fk(int x1,int y1,int x2,int y2)
  9. {
  10. double k=(y1-y2)/(x1-x2);
  11. return k;
  12. }
  13.  
  14. double fb(double k, int y1, int x1)
  15. {
  16. double b=y1-k*x1;
  17. return b;
  18. }
  19.  
  20. double findx(double k1, double k2,double b1,double b2)
  21. {
  22. double x=(b2-b1)/(k1-k2);
  23. return x;
  24. }
  25. double findy(double x,int y1)
  26. {
  27. double y=x*y1;
  28. }
  29. double fa(double y1,double y2)
  30. {
  31. return y1-y2;
  32. }
  33.  
  34. double fb(double x1,double x2)
  35. {
  36. return x2-x1;
  37. }
  38. double fc(double x1,double x2,double y1,double y2)
  39. {
  40. return x1 * y2 - x2 * y1;
  41. }
  42. int main()
  43. { cout.precision(15);
  44. cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
  45. a1 = fa(y1,y2);
  46. b1 = fb(x1,x2);
  47. c1 = fc(x1,x2,y1,y2);
  48. a2 = fa(y3,y4);
  49. b2 = fb(x3,x4);
  50. c2 =fc(x3,y3,x4,y4);
  51.  
  52. if(a1 * b2 - a2 * b1 == 0)
  53. {
  54. if(a1 * c2 - a2 * c1 == 0 && b1 * c2 - b2 * c1 == 0 )
  55. {
  56. cout << 2 << '\n';
  57. }
  58. else
  59. {
  60. cout << 0 << '\n';
  61. }
  62. }
  63. else
  64. {
  65. x = (((c1 * b2) - (c2 * b1)) / ((a1 * b2) - (a2 * b1)));
  66. y = (((a1 * c2) -(a2 * c1)) / ((a1 * b2) - (a2 * b1)));
  67. x *= -1;
  68. y *= -1;
  69. if(a1 == a2 && b1 == b2 && c1 == c2)
  70. {
  71. cout << 2 << '\n';
  72. }
  73. else
  74. {
  75.  
  76. cout << fixed << 1 << " " << x << " " << y << '\n';
  77. }
  78. }
  79.  
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement