Loan198

Untitled

Nov 13th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Vector {
  5. double x;
  6. double y;
  7. Vector ()
  8. {
  9. x = 0;
  10. y = 0;
  11. }
  12. Vector (double _x, double _y){
  13. x = _x;
  14. y = _y;
  15. }
  16. void printVector(){
  17. cout << x << " "<< y;
  18. }
  19. };
  20.  
  21. Vector addVector(Vector v1, Vector v2)
  22. {
  23. // Them code cua ban o day
  24. Vector a;
  25. a.x = v1.x + v2.x;
  26. a.y = v1.y + v2.y;
  27. return a;
  28. }
  29.  
  30. int main()
  31. {
  32. Vector v1, v2;
  33. cin>> v1.x>> v1.y>> v2.x>> v2.y;
  34. Vector a = addVector ( v1, v2);
  35. Vector ( a.x, a.y);
  36. a.printVector();
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment