-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlamda_exp2.cpp
50 lines (32 loc) · 880 Bytes
/
lamda_exp2.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
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<int> inp = { 1 , 5 , 2 , 3 ,4 };
sort(inp.begin(),inp.end(),[](int i , int j ){ return i < j ; } ) ;
for( auto x : inp)
cout << x << " " ;
cout << "\n";
/***** vector with pairs ******/
cout <<"----" << "\n";
vector<pair < int , int > > jk;
jk.push_back(make_pair(1,1));
jk.push_back(make_pair(2,2));
jk.push_back(make_pair(-1,-1));
jk.push_back(make_pair(-1,2));
sort(jk.begin(),jk.end());
for(auto x : jk )
{
cout << x.first << " " << x.second << "\n";
}
sort(jk.begin(),jk.end(), [](pair<int,int> i , pair<int,int> j ) { if ( i.first == j.first ) return (i.second > j.second); return i.first < j.first;} ) ;
cout <<"----" << "\n";
for(auto x : jk )
{
cout << x.first << " " << x.second << "\n";
}
return 0;
}