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