Advertisement
vardgrig

Pryamaya

Mar 4th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <list>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <vector>
  7. using namespace std;
  8. struct Point
  9. {
  10.     double x,y;
  11. };
  12. struct Line
  13. {
  14.     double a,b,c;
  15. };
  16. void LineFromTwoPoints(Point a, Point b)
  17. {
  18.     Line l;
  19.     l.a = (b.y - a.y) / (b.x - a.x);
  20.     l.b = 1;
  21.     l.c = b.y - l.a * b.x;
  22.     cout << "y = " << l.a << "x + " << l.c;
  23. }
  24. bool isPointOnLine(Point m, Line n)
  25. {
  26.     return (n.a*m.x + n.b*m.y + n.c == 0);
  27. }
  28.  
  29. int main()
  30. {
  31.     Point m;
  32.     Line n;
  33.     cin >> m.x >> m.y >> n.a >> n.b >> n.c;
  34.     cout << (isPointOnLine(m, n) ? "Yes\n" : "No\n");
  35.    
  36.     Point A, B;
  37.     cin >> A.x >> A.y >> B.x >> B.y;
  38.     LineFromTwoPoints(A,B);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement