fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. struct point{
  5. int x,y;
  6.  
  7. };
  8. point operator-(point p1){
  9. point ret;
  10. ret.x = -p1.x;
  11. ret.y = -p1.y;
  12. return ret;
  13. }
  14. point operator-(point p1,point p2){
  15. point ret;
  16. ret.x = p1.x - p2.x;
  17. ret.y = p1.y - p2.y;
  18. return ret;
  19. }
  20. int main() {
  21. point p1, p2;
  22. p1.x = 10, p1.y = 20;
  23. p2.x = 5, p2.y = 5;
  24. point p_one = -p1, p_two = p1-p2 ;
  25. printf("%d %d\n%d %d",p_one.x, p_one.y,p_two.x, p_two.y);
  26. return 0;
  27. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
-10 -20
5 15