Advertisement
nq1s788

геома

Aug 15th, 2024 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. typedef long double ld;
  2.  
  3. struct vect {
  4.     ld x, y;
  5.     vect(): x(0), y(0) {}
  6.     vect(ld x, ld y): x(x), y(y) {}
  7.     vect(vect a, vect b): x(b.x - a.x), y(b.y - a.y) {}
  8. };
  9.  
  10. vect operator+(vect a, vect b) {
  11.     return vect(a.x + b.x, a.y + b.y);
  12. }
  13.  
  14. ld operator*(vect a, vect b) {
  15.     return a.x * b.x + a.y * b.y;
  16. }
  17.  
  18. vect operator*(vect a, ld k) {
  19.     return vect(a.x * k, a.y * k);
  20. }
  21.  
  22. ld operator^(vect a, vect b) {
  23.     return a.x * b.y - b.x * a.y;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement