-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector(basics)
More file actions
51 lines (43 loc) · 903 Bytes
/
vector(basics)
File metadata and controls
51 lines (43 loc) · 903 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
50
51
#include<iostream>
#include<vector>
using namespace std;
int main()
{ //declaration
vector<int> a;
vector<int>b(5,10);
vector<int>c(b.begin(),b.end());
vector<int>d{1,2,3,4};
//iteration
for(int i=0;i<d.size();i++)
{
cout<<d[i]<<",";
}cout<<endl;
for(auto it=b.begin();it!=b.end();it++)
{
cout<<(*it)<<",";
}
cout<<endl;
for(auto x:d)
{
cout<<x<<",";
}
cout<<endl;
//user inpu
vector<int>v;
int n;
cin>>n;
for(
int i=0;i<n;i++)
{
int no;
cin>>no;
v.push_back(no);
}
//func
cout<<v.size()<<endl;
cout<<v.capacity()<<endl;
cout<<v.max_size()<<endl;
cout<<d.size()<<endl;
cout<<d.capacity()<<endl;
cout<<d.max_size()<<endl;
}