Guest User

Untitled

a guest
Nov 17th, 2019
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. unsigned long long int n, p, i;
  4. char c;
  5. struct Doi
  6. {
  7. char prenume[260], nume[260];
  8. unsigned long long int salariu, varsta;
  9. char functie[260], numar[260], email[260];
  10. } v[100];
  11. bool cmp1(Doi a, Doi b)
  12. {
  13. if(strcmp(a.prenume, b.prenume)!=0)
  14. return strcmp(a.prenume, b.prenume)<0;
  15. }
  16. bool cmp2(Doi a, Doi b)
  17. {
  18. if(strcmp(a.nume, b.nume)!=0)
  19. return strcmp(a.nume, b.nume)<0;
  20. }
  21. bool cmp3(Doi a, Doi b)
  22. {
  23. if(a.salariu!=b.salariu)
  24. return a.salariu<b.salariu;
  25. }
  26. bool cmp4(Doi a, Doi b)
  27. {
  28. if(a.varsta!=b.varsta)
  29. return a.varsta<b.varsta;
  30. }
  31. bool cmp5(Doi a, Doi b)
  32. {
  33. if(strcmp(a.functie, b.functie)!=0)
  34. return strcmp(a.functie, b.functie)<0;
  35. }
  36. bool cmp6(Doi a, Doi b)
  37. {
  38. if(strcmp(a.numar, b.numar)!=0)
  39. return strcmp(a.numar, b.numar)<0;
  40. }
  41. bool cmp7(Doi a, Doi b)
  42. {
  43. if(strcmp(a.email, b.email)!=0)
  44. return strcmp(a.email, b.email)<0;
  45. }
  46.  
  47. bool cmp8(Doi a, Doi b)
  48. {
  49. if(strcmp(a.prenume, b.prenume)!=0)
  50. return strcmp(a.prenume, b.prenume)>0;
  51. }
  52. bool cmp9(Doi a, Doi b)
  53. {
  54. if(strcmp(a.nume, b.nume)!=0)
  55. return strcmp(a.nume, b.nume)>0;
  56. }
  57. bool cmp10(Doi a, Doi b)
  58. {
  59. if(a.salariu!=b.salariu)
  60. return a.salariu>b.salariu;
  61. }
  62. bool cmp11(Doi a, Doi b)
  63. {
  64. if(a.varsta!=b.varsta)
  65. return a.varsta>b.varsta;
  66. }
  67. bool cmp12(Doi a, Doi b)
  68. {
  69. if(strcmp(a.functie, b.functie)!=0)
  70. return strcmp(a.functie, b.functie)>0;
  71. }
  72. bool cmp13(Doi a, Doi b)
  73. {
  74. if(strcmp(a.numar, b.numar)!=0)
  75. return strcmp(a.numar, b.numar)>0;
  76. }
  77. bool cmp14(Doi a, Doi b)
  78. {
  79. if(strcmp(a.email, b.email)!=0)
  80. return strcmp(a.email, b.email)>0;
  81. }
  82. int main()
  83. {
  84. cin>>n;
  85. for(i=1; i<=n; i++)
  86. cin>>v[i].prenume>>v[i].nume>>v[i].salariu>>v[i].varsta>>v[i].functie>>v[i].numar>>v[i].email;
  87. cin>>p>>c;
  88. if(p==1)
  89. if(c=='+')
  90. stable_sort(v+1, v+n+1, cmp1);
  91. else
  92. stable_sort(v+1, v+n+1, cmp8);
  93. else if(p==2)
  94. if(c=='+')
  95. stable_sort(v+1, v+n+1, cmp2);
  96. else
  97. stable_sort(v+1, v+n+1, cmp9);
  98. else if(p==3)
  99. if(c=='+')
  100. stable_sort(v+1, v+n+1, cmp3);
  101. else
  102. stable_sort(v+1, v+n+1, cmp10);
  103. else if(p==4)
  104. if(c=='+')
  105. stable_sort(v+1, v+n+1, cmp4);
  106. else
  107. stable_sort(v+1, v+n+1, cmp11);
  108. else if(p==5)
  109. if(c=='+')
  110. stable_sort(v+1, v+n+1, cmp5);
  111. else
  112. stable_sort(v+1, v+n+1, cmp12);
  113. else if(p==6)
  114. if(c=='+')
  115. stable_sort(v+1, v+n+1, cmp6);
  116. else
  117. stable_sort(v+1, v+n+1, cmp13);
  118. else if(p==7)
  119. if(c=='+')
  120. stable_sort(v+1, v+n+1, cmp7);
  121. else
  122. stable_sort(v+1, v+n+1, cmp14);
  123. for(i=1; i<=n; i++)
  124. cout<<v[i].prenume<<' '<<v[i].nume<<' '<<v[i].salariu<<' '<<v[i].varsta<<' '<<v[i].functie<<' '<<v[i].numar<<' '<<v[i].email<<'\n';
  125. return 0;
  126. }
RAW Paste Data