-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathranklist.cpp
More file actions
33 lines (33 loc) · 780 Bytes
/
ranklist.cpp
File metadata and controls
33 lines (33 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <bits/stdc++.h>
using namespace std;
bool sortbythird(tuple<string,int,int>t1,tuple<string,int,int>t2)
{
if(get<2>(t1)!=get<2>(t2))
return get<2>(t1)>get<2>(t2);
else if(get<0>(t1)!=get<0>(t2))
return get<0>(t1)<get<0>(t2);
else if(get<1>(t1)!=get<1>(t2))
return get<1>(t1)<get<1>(t2);
}
int main()
{
int n,rollno,marks,rank;
string s;
vector<tuple<string ,int ,int,int> > stud;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> s;
cin >> rollno;
cin >> marks;
cin >> rank;
stud.push_back(make_tuple(s,rollno,marks,rank));
}
sort(stud.begin(),stud.end(),sortbythird);
cout << "-------------------------------------------\n";
for(int i=0;i<n;i++)
{
cout << get<0>(stud[i]) << " " << get<1>(stud[i]) << " " << get<2>(stud[i]) << endl;
}
return 0;
}