Advertisement
mehedi1

Untitled

Sep 27th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct Data {
  4.     int roll, mark;
  5.     string name;
  6. } A[105];
  7.  
  8. bool cmp(Data a, Data b) {
  9.     if(a.mark==b.mark) return a.roll<b.roll;
  10.     return a.mark>b.mark;
  11. }
  12.  
  13. int main() {
  14.     //freopen("D:/a.out","w",stdout);
  15.     int a,b,n,T,cas=0;
  16.     cin>>n;
  17.     for(int i=0;i<n;++i) {
  18.         cin>>A[i].roll>>A[i].name>>A[i].mark;
  19.     }
  20.     sort(A, A+n, cmp);
  21.     printf("Roll | Name       | Marks\n");
  22.     printf("-------------------------");
  23.     for(int i=0;i<n;++i) {
  24.         printf("\n");
  25.         cout.width(4); cout<<right<<A[i].roll<<" | ";
  26.         cout.width(10); cout<<left<<A[i].name<<" | ";
  27.         cout<<left<<A[i].mark;
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement