Guest User

Untitled

a guest
Jun 29th, 2017
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. struct p{
  5.     int a;
  6.     int b;
  7.     int c;
  8.  
  9.     p(int d , int e , int f){
  10.         a = d;
  11.         b = e;
  12.         c = f;
  13.     }
  14.  
  15.     bool operator < (const p& A){
  16.         if(a != A.a){
  17.             return a < A.a;
  18.         }
  19.         if(b != A.b){
  20.             return b < A.b;
  21.         }
  22.         return c < A.c;
  23.     }
  24.  
  25.     bool operator == (const p & A){
  26.         if(A.a == a && A.b == b && A.c == c){
  27.             return true;
  28.         }
  29.         return false;
  30.     }
  31. };
  32.  
  33. bool comp(p a , p b){
  34.         if(a.a != b.a){
  35.             return a.a < b.a;
  36.         }
  37.         if(a.b != b.b){
  38.             return a.b < b.b;
  39.         }
  40.         return a.c < b.c;
  41. }
  42. int main()
  43. {
  44.     vector < p > a;
  45.     a.emplace_back(p(1,2,3));
  46.     a.emplace_back(p(2,3,4));
  47.     a.emplace_back(p(3,3,5));
  48.  
  49.     sort(a.begin() , a.end(), comp);
  50.  
  51.     auto j = *lower_bound(a.begin() , a.end() , p(1 , 2 , 3));
  52.     cout << j.a << " " << j.b << " " << j.c << endl;
  53. }
Add Comment
Please, Sign In to add comment