-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgorithm_sort3.cpp
33 lines (27 loc) · 950 Bytes
/
Algorithm_sort3.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
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool compare(pair<string,pair<int, int>> a,
pair<string,pair<int, int>> b){
if(a.second.first == b.second.first){
return a.second.second > b.second.second;
}
else{
return a.second.first > b.second.first;
}
}
int main(void){
// 이중pair를 통해서 세 변수를 묶어줌
vector<pair<string,pair<int, int>>> v;
v.push_back(pair<string,pair<int, int>>("90 JSH", pair<int,int>(90, 19961222)));
v.push_back(pair<string,pair<int, int>>("69 HMS", pair<int,int>(69, 19931222)));
v.push_back(pair<string,pair<int, int>>("85 SSH", pair<int,int>(85, 19971222)));
v.push_back(pair<string,pair<int, int>>("70 KMJ", pair<int,int>(70, 19981222)));
v.push_back(pair<string,pair<int, int>>("70 OHJ", pair<int,int>(70, 19991222)));
sort(v.begin(), v.end(), compare);
for(int i =0; i <v.size(); i++){
cout << v[i].first << ' ' <<"\n";
}
return 0;
}