-
Notifications
You must be signed in to change notification settings - Fork 0
/
pta1028.cpp
55 lines (47 loc) · 1 KB
/
pta1028.cpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h> //导入万能库
#define MAX 101
#define INF 0x7fffffff
using namespace std;
struct node{
string id;
string name;
int score;
};
vector<node>ans;
bool cmp1(node a,node b)
{
return a.id<b.id;
}
bool cmp2(node a,node b)
{
if(a.name!=b.name)
return a.name<b.name;
return a.id<b.id;
}
bool cmp3(node a,node b)
{
if(a.score!=b.score)
return a.score<b.score;
return a.id<b.id;
}
int main(void)
{
int n,num,pos=1,type;cin>>n>>type;
node tem;
for(int i=0;i<n;++i)
{
cin>>tem.id>>tem.name>>tem.score;
ans.push_back(tem);
}
if(type==1)
sort(ans.begin(),ans.end(),cmp1);
else if(type==2)
sort(ans.begin(),ans.end(),cmp2);
else if(type==3)
sort(ans.begin(),ans.end(),cmp3);
for(int i=0;i<n;++i)
{
cout<<ans[i].id<<" "<<ans[i].name<<" "<<ans[i].score<<endl;
}
}
// accomplish