-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvector.cpp
More file actions
36 lines (36 loc) · 785 Bytes
/
vector.cpp
File metadata and controls
36 lines (36 loc) · 785 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
#include<bits/stdc++.h>
using namespace std;
int main(){
// vector<int>v1;
// v1.push_back(2);
// v1.push_back(3);
// v1.push_back(5);
// for(auto &x:v1){
// cout<<x<<" ";
// }
// cout<<endl;
// cout<<"size : "<<v1.size()<<" capacity : "<<v1.capacity();
vector<int>v(5,1);
if(v.empty()){
cout<<"empty";
}
else{
cout<<"not empty";
}
v.pop_back();
for(auto &x:v){
cout<<x<<" ";
}
vector<int>::iterator it=v.begin();
while(it!=v.end()){
cout<<(*it)<<endl;
it++;
}
cout<<"next itr";
vector<int>::reverse_iterator it1= v.rbegin();
while(it1!=v.rend()){
cout<<(*it1)<<endl;
it1++;
}
return 0;
}