forked from Amitshu2003/All-Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectoruse.cpp
More file actions
50 lines (37 loc) · 798 Bytes
/
vectoruse.cpp
File metadata and controls
50 lines (37 loc) · 798 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
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <vector>
using namespace std;
int main() {
//vector<int> * vp = new vector<int>();
vector<int> v;
for (int i = 0; i < 100; i++) {
cout << "cap:" << v.capacity() << endl;
cout << "size:" << v.size() << endl;
v.push_back(i + 1);
}
v.push_back(10);
v.push_back(20);
v.push_back(30);
v[1] = 100;
// dont use [] for inserting elements
//v[3] = 1002;
//v[4] = 1234;
v.push_back(23);
v.push_back(234);
v.pop_back();
/*
for (int i = 0; i < v.size(); i++) {
cout << v[i] << endl;
}
cout << v[0] << endl;
cout << v[1] << endl;
cout << v[2] << endl;
cout << v[3] << endl;
cout << v[4] << endl;
cout << v[5] << endl;
cout << v[6] << endl;
cout << "Size: " << v.size() << endl;
cout << v.at(2) << endl;
cout << v.at(6) << endl;
*/
}