-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithms.cpp
More file actions
53 lines (40 loc) · 1022 Bytes
/
Copy pathalgorithms.cpp
File metadata and controls
53 lines (40 loc) · 1022 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
52
53
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> v;
v.push_back(1);
v.push_back(4);
v.push_back(5);
v.push_back(7);
v.push_back(9);
v.push_back(10);
cout << "Finding 5 -> " << binary_search(v.begin(), v.end(), 5) << endl;
cout << "Finding 6 -> " << binary_search(v.begin(), v.end(), 6) << endl;
cout << "Lower bound of 7 -> " << lower_bound(v.begin(), v.end(), 7) - v.begin() << endl;
cout << "Upper bound of 7 -> " << upper_bound(v.begin(), v.end(), 7) - v.begin() << endl;
int a = 3;
int b = 5;
cout << "Max -> " << max(a, b) << endl;
cout << "Min -> " << min(a, b) << endl;
swap(a, b);
cout << a << "," << b << endl;
string abcd = "abcd";
reverse(abcd.begin(), abcd.end());
cout << abcd << endl;
rotate(v.begin(), v.begin() + 1, v.end());
for (int i : v)
{
cout << i << " ";
}
cout << endl;
sort(v.begin(), v.end());
for (int i : v)
{
cout << i << " ";
}
cout << endl;
return 0;
}