Guest User

Untitled

a guest
Jun 29th, 2017
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 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.         if(c != A.c){
  23.             return c < A.c;
  24.         }
  25.     }
  26.  
  27.     bool operator == (const p & A){
  28.         if(A.a == a && A.b == b && A.c == c){
  29.             return true;
  30.         }
  31.         return false;
  32.     }
  33. };
  34.  
  35. bool comp(p a , p b){
  36.         if(a.a != b.a){
  37.             return a.a < b.a;
  38.         }
  39.         if(a.b != b.b){
  40.             return a.b < b.b;
  41.         }
  42.         if(a.c != b.c){
  43.             return a.c < b.c;
  44.         }
  45. }
  46. int main()
  47. {
  48.     vector < p > a;
  49.     a.emplace_back(p(1,2,3));
  50.     a.emplace_back(p(2,3,4));
  51.     a.emplace_back(p(3,3,5));
  52.  
  53.     sort(a.begin() , a.end(), comp);
  54.  
  55.     auto j = *lower_bound(a.begin() , a.end() , p(1 , 2 , 2));
  56.     cout << j.a << " " << j.b << " " << j.c << endl;
  57. }
Add Comment
Please, Sign In to add comment