fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct dot
  5. {
  6. int x, y;
  7. dot(){
  8. cin >> x >> y;
  9. }
  10. };
  11. struct square
  12. {
  13. dot upper_left, lower_right;
  14. bool is_point_on(dot &p) const
  15. {
  16. return p.x < lower_right.x and p.x > upper_left.x and p.y < upper_left.y and p.y > lower_right.y;
  17. }
  18. bool is_point_in(dot &p) const
  19. {
  20. return p.x <= lower_right.x and p.x >= upper_left.x and p.y <= upper_left.y and p.y >= lower_right.y;
  21. }
  22. };
  23.  
  24. int main() {
  25. square black, white;
  26. dot point;
  27. cout << ((black.is_point_in(point) and not white.is_point_on(point))?"HAPPY":"SAD");
  28. }
Success #stdin #stdout 0s 4852KB
stdin
2 10 5 3 4 4 6 1 2 9
stdout
HAPPY