Advertisement
saira12tabassum19

Untitled

Sep 27th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 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,min,lk,last; 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. if(i==0){min=name.size();}
  19.  
  20. last=name.size();
  21. if(min>last){min=last;}
  22.  
  23. vec.push_back(make_pair(-mark,roll));
  24. s.insert({roll,name});
  25.  
  26.  
  27. }
  28. sort(vec.begin(),vec.end());
  29.  
  30. cout<<"Roll | Name"; for(int h=0;h<11-4;h++){cout<<" ";}
  31. cout<<"| Marks"<<endl;
  32.  
  33.  
  34. cout<<"-------------------------"<<endl; int l=vec.size();
  35.  
  36. int k=0,temp;
  37.  
  38.  
  39. for(int it=0;it<l;it++)
  40. { temp=vec[it].second;
  41. while(temp!=0)
  42. {
  43. temp=temp/10;
  44. k++;
  45. }
  46. if(k==1)cout<<" ";
  47. else if(k==2)cout<<" ";
  48. else if(k==3)cout<<" ";
  49.  
  50. lk=s[vec[it].second].size();
  51.  
  52. cout<<vec[it].second<<" | "<<s[vec[it].second];
  53.  
  54. for(int m=0;m<11-lk;m++){cout<<" ";}
  55. cout<<"| "<<-(vec[it].first)<<endl;
  56.  
  57.  
  58.  
  59.  
  60. k=0;
  61. }
  62.  
  63.  
  64.  
  65.  
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement