Skip to content

Commit 19d0c41

Browse files
Vector Capacity
1 parent 0a65efd commit 19d0c41

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

output.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
2 10 3
2-
3
1+
7
2+
10 20 50 50 50 50 50

vector-capacity.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
vector<int> v;
7+
v.push_back(10);
8+
v.push_back(20);
9+
v.push_back(30);
10+
v.push_back(40);
11+
v.push_back(50);
12+
13+
v.resize(2);
14+
v.resize(7, 50);
15+
cout << v.size() << endl;
16+
for (int i : v)
17+
{
18+
cout << i << " ";
19+
}
20+
21+
/* v.clear();
22+
cout << v.size() << endl;
23+
for (int i : v)
24+
{
25+
cout << i << " ";
26+
}
27+
28+
cout << v[4] << endl; */
29+
// cout << v.max_size() << endl;
30+
/* cout << v.capacity() << endl;
31+
v.push_back(10);
32+
cout << v.capacity() << endl;
33+
v.push_back(20);
34+
cout << v.capacity() << endl;
35+
v.push_back(30);
36+
cout << v.capacity() << endl;
37+
v.push_back(40);
38+
cout << v.capacity() << endl;
39+
v.push_back(50);
40+
cout << v.capacity() << endl; */
41+
42+
return 0;
43+
}

vector-capacity.exe

89 KB
Binary file not shown.

0 commit comments

Comments
 (0)