Advertisement
dumitreskw

1013

Jan 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. struct aniversare
  4. {
  5. int a,l,z;
  6. };
  7. aniversare v[1001];
  8. int n;
  9.  
  10. void citire()
  11. {
  12. int i;
  13. cin>>n;
  14. for(i=1;i<=n;i++)
  15. cin>>v[i].a>>v[i].l>>v[i].z;
  16. }
  17.  
  18. void rezolvare()
  19. {
  20. int pmax=1,pmin=1,i;
  21. for(i=2;i<=n;i++)
  22. {
  23. if(v[i].a>v[pmax].a)
  24. pmax=i;
  25. else
  26. if(v[i].a==v[pmax].a&&v[i].l>v[pmax].l)
  27. pmax=i;
  28. else
  29. if(v[i].a==v[pmax].a&&v[i].l==v[pmax].l&&v[i].z>v[pmax].z)
  30. pmax=i;
  31.  
  32. if(v[i].a<v[pmin].a)
  33. pmin=i;
  34. else
  35. if(v[i].a==v[pmin].a&&v[i].l<v[pmin].l)
  36. pmin=i;
  37. else
  38. if(v[i].a==v[pmin].a&&v[i].l==v[pmin].l&&v[i].z<v[pmin].z)
  39. pmin=i;
  40. }
  41. cout<<pmax<<" "<<pmin;
  42. }
  43.  
  44. int main()
  45. {
  46. citire();
  47. rezolvare();
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement