-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvector.cpp
49 lines (32 loc) · 859 Bytes
/
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
43
44
45
46
47
48
49
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> someVec;
vector<string> anotherVec(3);
someVec.push_back(1);
someVec.push_back(2);
someVec.push_back(3);
cout<<"someVec size "<<someVec.size()<<endl;
anotherVec[0]="Dhruv";
anotherVec[1]="hahah";
anotherVec[2]="lol";
anotherVec.push_back("shananana");
for(int var:someVec)
{
cout<< var<<endl;
}
for( string name:anotherVec)
{
cout<< name<<endl;
}
cout<<"another vec size "<<anotherVec.size()<<endl;
cout<<"Front and back: "<<endl;
cout<<"the front is: "<<anotherVec.front()<<endl;
cout<<"the back is: "<<anotherVec.back()<<endl;
anotherVec.pop_back();
anotherVec.insert(anotherVec.begin(),"DON");
cout<<"now the front is: "<<anotherVec.front()<<endl;
cout<<"now the back is: "<<anotherVec.back()<<endl;
return 0;
}