Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct p{
- int a;
- int b;
- int c;
- p(int d , int e , int f){
- a = d;
- b = e;
- c = f;
- }
- bool operator < (const p& A){
- if(a != A.a){
- return a < A.a;
- }
- if(b != A.b){
- return b < A.b;
- }
- if(c != A.c){
- return c < A.c;
- }
- }
- bool operator == (const p & A){
- if(A.a == a && A.b == b && A.c == c){
- return true;
- }
- return false;
- }
- };
- bool comp(p a , p b){
- if(a.a != b.a){
- return a.a < b.a;
- }
- if(a.b != b.b){
- return a.b < b.b;
- }
- if(a.c != b.c){
- return a.c < b.c;
- }
- }
- int main()
- {
- vector < p > a;
- a.emplace_back(p(1,2,3));
- a.emplace_back(p(2,3,4));
- a.emplace_back(p(3,3,5));
- sort(a.begin() , a.end(), comp);
- auto j = *lower_bound(a.begin() , a.end() , p(1 , 2 , 2));
- cout << j.a << " " << j.b << " " << j.c << endl;
- }
Add Comment
Please, Sign In to add comment