-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
127 lines (104 loc) · 2.26 KB
/
Copy pathmain.cpp
File metadata and controls
127 lines (104 loc) · 2.26 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include<iostream>
#include<utility>
#include<vector>
//Practice for DSA
//#include<bits/stdc++.h>
using namespace std;
void vector_function(){
vector<int> vec={4,4};
// vector<int> vec2={3,3};
// \\swap(vec,vec2);
vec.push_back(1);
vec.push_back(2);
vec.push_back(10);
vec.push_back(3);
vec.insert(vec.begin()+2,5);
for(auto i:vec){
cout<<i<<" ";
}
cout<<endl;
// auto reversebegin= vec.rbegin();
// auto reverseend= vec.rend();
// for(auto i =reversebegin;i<reverseend;i++){ // FOR PRINTING IN REVERSE ORDER
// cout<<*i<<" ";
// }
// vec.erase(vec.begin()+1,vec.end()-1
// );
// for(auto i: vec){
// cout<<i<<" ";
// }
// cout<<vec[2];
}
void explain_stack(){
stack<int> st;
st.push(1);
st.push(2);
st.push(3);
while(st.empty()==false){
cout<<st.top();
st.pop();
}
}
void explain_queue(){
// queue<int> q;
// q.push(1);
// q.push(2);
// q.push(3);
// while(q.empty()==false){
// cout<<q.front()<<" ";
// q.pop();
// }
priority_queue<int> pq;
pq.push(1);
pq.push(10);
pq.push(6);
// cout<<pq.top();
while(pq.empty()==false){
cout<<pq.top()<<" ";
pq.pop();
}
}
void explain_set(){
set<int> st;
st.insert(10);
st.insert(33);
st.insert(42);
st.insert(42); // DOESNT ALLOW DUPLICATES
st.insert(12);
for(auto i: st){
cout<<i<<" ";
}
cout<<endl;
cout<< "Multiset is heree"<<endl;
multiset<int> ms;
ms.insert(10);
ms.insert(33);
ms.insert(42);
ms.insert(42); // ALLOWS DUPLICATES
ms.insert(12);
for(auto itr: ms){
cout<<itr<<" ";
}
cout<<endl;
auto it=ms.erase(ms.find(42));
for(auto it: ms){
cout<<it<<" ";
}
// cout<<endl;
// auto it =st.find(12);
// if(it!=st.end()){
// cout<<*it<<" ";
// }
}
void explain(){
int arr[5]={6, 2 , 4 ,5 ,1};
cout<<accumulate(arr,arr+5,2);
}
int main(){
explain();
return 0;
// pair<int,int>pr1={2,8};
// cout<<pr1.first<<" "<<pr1.second;
// pair<pair<int,int>,char> pr1={{10,20},'R'};
// cout<<pr1.second;
}