-
Notifications
You must be signed in to change notification settings - Fork 0
/
Algo.cpp
47 lines (37 loc) · 1.02 KB
/
Algo.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
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
v.push_back(1);
v.push_back(3);
v.push_back(6);
v.push_back(7);
cout << "Finding 6-> " << binary_search(v.begin(), v.end(), 6) << endl;
cout << "lower bound-> " << lower_bound(v.begin(), v.end(), 6) - v.begin() << endl;
cout << "Uppper bound-> " << upper_bound(v.begin(), v.end(), 4) - v.begin() << endl;
int a = 3;
int b = 5;
cout << "max -> " << max(a, b);
cout << "min -> " << min(a, b);
swap(a, b);
cout << endl
<< "a-> " << a << endl;
string abcd = "abcd";
reverse(abcd.begin(), abcd.end());
cout << "string-> " << abcd << endl;
rotate(v.begin(), v.begin() + 1, v.end());
cout << "after rotate" << endl;
for (int i : v)
{
cout << i << " ";
}
sort(v.begin(), v.end());
cout << "after sorting" << endl;
for (int i : v)
{
cout << i << " ";
}
}