Advertisement
TAHMID37

structure sort

Jul 15th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.44 KB | None | 0 0
  1. /*  TAHMID RAHMAN
  2.     DAMIAN FOREVER
  3.      MATH LOVER
  4.     NEVER GIVE UP
  5. */
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define pi acos(-1.0)
  9. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  10. #define ll long long
  11. #define pb push_back
  12. #define fi first
  13. #define se second
  14. #define in insert
  15. #define mp make_pair
  16. #define GCD(a,b) __gcd(a,b);
  17. #define endl "\n"
  18. #define FRU freopen("out.txt","w",stdout)
  19. #define FRO freopen("in.txt","r",stdin)
  20. #define INFLL 9223372036854775807
  21. #define debug 0
  22. #define MAXN   100001
  23. #define ar array
  24. const int mxN=2e5;
  25. const int MOD=1e9+7;
  26. bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
  27. //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
  28.  struct info{
  29.  
  30.    string name;
  31.    int height,weight;
  32.    ll income;
  33.  
  34.  
  35. };
  36. bool comp(info a,info b)
  37. {
  38.    if(a.income==b.income)
  39.    {
  40.        if(a.height==b.height)
  41.        {
  42.            if(a.weight==b.weight)
  43.            {
  44.                return a.name<b.name;
  45.            }
  46.            else
  47.            {
  48.                return a.weight<b.weight;
  49.            }
  50.        }
  51.        else
  52.           return a.height>b.height;
  53.    }
  54.    else
  55.     return a.income>b.income;
  56.  
  57. }
  58. int main()
  59. {
  60.  
  61.    info a[4];
  62.    int i;
  63.    for(i=0;i<2;i++)
  64.    {
  65.       string s;
  66.       cin>>s;
  67.       a[i].name=s;
  68.        int x,y;
  69.        cin>>x;
  70.        a[i].height=x;
  71.        cin>>y;
  72.        a[i].weight=y;
  73.        ll z;
  74.        cin>>z;
  75.        a[i].income=z;
  76.  
  77.    }
  78.    sort(a,a+2,comp);
  79.    for(i=0;i<2;i++)
  80.    {
  81.        cout<<"Name :"<<a[i].name<<endl;
  82.        cout<<"Income :"<<a[i].income<<endl;
  83.        cout<<"Height :"<<a[i].height<<endl;
  84.        cout<<"Weight :"<<a[i].weight<<endl;
  85.        cout<<endl;
  86.    }
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.   /*stack<ll>st;
  107.     st.push(1);
  108.     st.push(2);
  109.     st.push(3);
  110.     st.push(4);
  111.     st.push(2);
  112.     while(!st.empty())
  113.     {
  114.         cout<<st.top()<<endl;
  115.         st.pop();
  116.     }
  117.     cout<<endl;
  118.     queue<ll>q;
  119.     q.push(1);
  120.     q.push(10);
  121.     q.push(2);
  122.     q.push(3);
  123.     while(!q.empty())
  124.      {
  125.          cout<<q.front()<<endl;
  126.          q.pop();
  127.      }
  128.      cout<<endl;
  129.      priority_queue<ll>pq;
  130.      pq.push(100);
  131.      pq.push(10001);
  132.      pq.push(3);
  133.      pq.push(11111111111);
  134.      pq.push(0);
  135.      while(!pq.empty())
  136.      {
  137.          cout<<pq.top()<<endl;
  138.          pq.pop();
  139.      }
  140.      cout<<endl;*/
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement