Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<vector>
  6. #include<string>
  7. #include<list>
  8. using namespace std;
  9.  
  10. class Elev{
  11. public:
  12. string nume;
  13. float n1;
  14. Elev(string nume,float n1){
  15. this->nume=nume;
  16. this->n1=n1;
  17.  
  18. }
  19. bool operator<(Elev &e){
  20. if(n1<e.n1)
  21. return false;
  22. else if(n1>e.n1)
  23. return true;
  24. else{
  25. if(nume<e.nume)
  26. return true;
  27. else
  28. return false;
  29. }
  30. }
  31. };
  32.  
  33. int main(){
  34. float n1;
  35. char nume[64];
  36. vector<Elev> elevi;
  37. while(EOF!=scanf("%[^,],%f\n",nume,&n1)){
  38. bool exista=false;
  39. for(int i=0;i<elevi.size();i++){
  40. if(elevi[i].nume==nume)exista=true;
  41. }
  42. if(!exista)
  43. elevi.emplace_back(nume,n1);
  44. }
  45. sort(elevi.begin(),elevi.end());
  46. for(int i=0;i<elevi.size();i++){
  47. printf("%s,%.2f\n",elevi[i].nume.c_str(),elevi[i].n1);
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement