Advertisement
zhukov000

Simple geometry

Nov 8th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. const long double PI = acos(-1.0);
  3.  
  4. using namespace std;
  5.  
  6. struct Point
  7. {
  8.   int x, y;
  9.   Point(int px = 0, int py = 0) : x(px), y(py) {}
  10. };
  11.  
  12. struct Vector
  13. {
  14.   int x, y;
  15.   Vector(int px = 0, int py = 0) : x(px), y(py) {};
  16.   Vector(Point p1, Point p2) : x(p2.x - p1.x), y(p2.y - p1.y) {}
  17. };
  18.  
  19. istream& operator>> (istream &in, Point & p)
  20. {
  21.   in >> p.x >> p.y;
  22.   return in;
  23. }
  24.  
  25. ostream& operator<< (ostream& out, const Vector & v)
  26. {
  27.   out << v.x << " " << v.y;
  28.   return out;
  29. }
  30.  
  31. int dot_product(Vector v1, Vector v2)
  32. {
  33.   return v1.x * v2.x + v1.y * v2.y;
  34. }
  35.  
  36. int cross_product(Vector v1, Vector v2)
  37. {
  38.   return v1.x * v1.y - v1.y * v2.x;
  39. }
  40.  
  41. signed main() {
  42.   std::ios::sync_with_stdio(false);
  43.   cin.tie(0);
  44.   freopen("INPUT.TXT", "r", stdin);
  45.   Point A, B, C;
  46.   cin >> A >> B >> C;
  47.   Vector AB(A,B), AC(A,C), BC(B,C);
  48.   cout << AB << endl;
  49.   cout << AC << endl;
  50.   cout << BC << endl;
  51.   return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement