daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct
  6. {
  7.     int a, l, z, nr;
  8. }d[1001], aux;
  9.  
  10. int maimare(int a1, int l1, int z1, int a2, int l2, int z2)
  11. {
  12.     if(a1<a2)
  13.         return 1;
  14.     else
  15.         if(a1==a2)
  16.             if(l1<l2)
  17.                 return 1;
  18.             else
  19.                 if(l1==l2 and z1<z2)
  20.                     return 1;
  21.     return 0;
  22. }
  23.  
  24. int main()
  25. {
  26.     int n, i, j;
  27.     cin>>n;
  28.     for(i=1;i<=n;i++)
  29.     {
  30.         cin>>d[i].a>>d[i].l>>d[i].z;
  31.         d[i].nr=i;
  32.     }
  33.     for(i=1;i<n;i++)
  34.         for(j=i+1;j<=n;j++)
  35.             if(maimare(d[i].a, d[i].l, d[i].z, d[j].a, d[j].l, d[j].z))
  36.             {
  37.                 aux=d[i];
  38.                 d[i]=d[j];
  39.                 d[j]=aux;
  40.             }
  41.     cout<<d[1].nr<<" "<<d[n].nr;
  42.     return 0;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top