Advertisement
saira12tabassum19

Untitled

Sep 27th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. vector<pair<int,int>>vec;
  7. map<int,string>s;
  8.  
  9. int n,roll,mark; string name;
  10. cin>>n;
  11.  
  12. for(int i=0;i<n;i++)
  13. {
  14. cin>>roll; cin.ignore(256,'\n');
  15. getline(cin,name);
  16. cin>>mark;
  17.  
  18. vec.push_back(make_pair(-mark,roll));
  19. s.insert({roll,name});
  20.  
  21.  
  22. }
  23. sort(vec.begin(),vec.end());
  24.  
  25. cout<<"Roll | Name | Marks"<<endl<<endl;
  26. cout<<"-------------------------"<<endl<<endl; int l=vec.size();
  27.  
  28. int k=0,temp;
  29.  
  30.  
  31. for(int it=0;it<l;it++)
  32. { temp=vec[it].second;
  33. while(temp!=0)
  34. {
  35. temp=temp/10;
  36. temp=temp%10;
  37. k++;
  38. }
  39.  
  40. if(k==1)
  41. cout<<" ";
  42. else if(k==2)
  43. cout<<" ";
  44. else cout<<"";
  45. cout<<vec[it].second<<" | "<<s[vec[it].second]<<" | "<<-(vec[it].first)<<endl;
  46.  
  47.  
  48.  
  49.  
  50. k=0;
  51. }
  52.  
  53.  
  54.  
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement