-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithms.cpp
More file actions
51 lines (34 loc) · 976 Bytes
/
Copy pathAlgorithms.cpp
File metadata and controls
51 lines (34 loc) · 976 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
int main(){
cout<<"---------------------sort arrays---------------------"<<endl;
int n=5;
int a[n]={3,4,1,5,6};
//sort arrays
sort(a,a+n);
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
cout<<endl;
cout<<"---------------------sort vectors---------------------"<<endl;
vector<int>v={3,4,1,5,6};
sort(v.begin(),v.end());
for(int val:v){
cout<<val<<" ";
}
cout<<endl;
cout<<"---------------------sort in descending---------------------"<<endl;
vector<int>v2={3,4,1,5,6};
sort(v2.begin(),v2.end(),greater<int>());
for(int val:v2){
cout<<val<<" ";
}
cout<<endl;
cout<<"---------------------sort vector of pairs---------------------"<<endl;
vector<pair<int,int>>p={{3,1},{2,1},{7,1},{5,2}};
sort(p.begin(),p.end());
for(auto pr:p){
cout<<pr.first<<" "<<pr.second<<endl;
}
cout<<endl;
}