Advertisement
Josif_tepe

Untitled

May 7th, 2025
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Point {
  6. private:
  7.     int x, y;
  8. public:
  9.     Point() {}
  10.     Point(int _x, int _y) {
  11.         x = _x;
  12.         y = _y;
  13.     }
  14.     Point operator + (Point tmp) {
  15.         return Point(x + tmp.x, y + tmp.y);
  16.     }
  17.     Point operator - (Point tmp) {
  18.         return Point(x - tmp.x, y - tmp.y);
  19.     }
  20.     Point operator * (Point tmp) {
  21.         return Point(x * tmp.x, y * tmp.y);
  22.     }
  23.     Point operator / (Point tmp) {
  24.         return Point(x / tmp.x, y / tmp.y);
  25.     }
  26.    
  27.     bool operator < (Point tmp) {
  28.         if(x < tmp.x and y < tmp.y) {
  29.             return true;
  30.         }
  31.         else {
  32.             return false;
  33.         }
  34.     }
  35.    
  36.     bool operator <= (Point tmp) {
  37.         if(x <= tmp.x and y <= tmp.y) {
  38.             return true;
  39.         }
  40.         else {
  41.             return false;
  42.         }
  43.     }
  44.     bool operator > (Point tmp) {
  45.         if(x > tmp.x and y > tmp.y) {
  46.             return true;
  47.         }
  48.         else {
  49.             return false;
  50.         }
  51.     }
  52.     bool operator >= (Point tmp) {
  53.         if(x >= tmp.x and y >= tmp.y) {
  54.             return true;
  55.         }
  56.         else {
  57.             return false;
  58.         }
  59.     }
  60.    
  61.     bool operator == (Point tmp) {
  62.         if(x == tmp.x and y == tmp.y) {
  63.             return true;
  64.         }
  65.         else {
  66.             return false;
  67.         }
  68.     }
  69.    
  70.     bool operator != (Point tmp) {
  71.         if(x != tmp.x or y != tmp.y) {
  72.             return true;
  73.         }
  74.         else {
  75.             return false;
  76.         }
  77.     }
  78.     void pechati() {
  79.         cout << x << " " << y << endl;
  80.     }
  81. };
  82. int main()
  83. {
  84.     Point a(3, 4);
  85.     Point b(5, 6);
  86.    
  87.     if(a < b) {
  88.         cout << "POMALO" << endl;
  89.     }
  90.    
  91.    
  92.    
  93.    
  94.     return 0;
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement