-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector.cpp
42 lines (32 loc) · 1.15 KB
/
vector.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
//Vectors Sequence Containers
//-> for revision and understanding. :)
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int>v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);
v.push_back(5);
//v.pop_back();
//v.resize(2); // for increasing the size
//cout<<v.size()<<endl; // for size of vectors
//for(int i = 0; i<v.size();i++){ // for printing the vector
//cout<<v[i]<<"";
//v.clear(); // for removing elements of vector
//cout<<v.empty()<<endl; // 0 if vector is not empty
//cout<<v.size()<<endl;
//v.erase(v.begin()+1); //pointing to the second element
//for(int i = 0; i<v.size();i++){
v.insert(v.begin()+1,8); // inserting 8 at second position
//for(int i = 0; i<v.size();i++)
// cout<<v[i]<<endl;
reverse(v.begin(),v.end()); // reverse the vector
// for(int i = 0; i<v.size();i++)
// cout<<v[i]<<endl;
sort(v.begin(),v.end());
for(int i = 0; i<v.size();i++)
cout<<v[i]<<endl;
}