-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector_array.cxx
More file actions
45 lines (34 loc) · 986 Bytes
/
Copy pathvector_array.cxx
File metadata and controls
45 lines (34 loc) · 986 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
#include<iostream>
//#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main() {
//vector declare
vector<int> ve;
int i,x,arr[]={1,2,8,9,4,7,11,10};
// x=*(&arr+1)-arr;
// cout<<x<<endl;
for(int i=0;i<(*(&arr+1)-arr);i++)
{
cout<<arr[i]<<" ";
}//1 2 8 9 4 7 11 10 0 0
int *max;
max=max_element(arr,arr+10);//(array,array+no of elements)
cout<<*max;// 11
ve.push_back(500); //500
ve.assign(5,10); // 10 10 10 10 10
ve.emplace_back(40); // 10 10 10 10 10 40
vector<int>:: iterator it=ve.begin();
// it store the address of vector begining element
for(vector<int>:: iterator it=ve.begin();it!=ve.end();it++)
{
cout<<*(it)<< " "; // // 10 10 10 10 10 40
}
for(auto it:ve)
{
cout<<it<<" ";
}
it=find(ve.begin(),ve.end(),40);// finding any element in vector
cout<<it - ve.begin()<<endl;
return 0;
}