We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2221d6c commit b4111a1Copy full SHA for b4111a1
C++/insertion_vector.cpp
@@ -0,0 +1,29 @@
1
+//inserting an element in array using vector
2
+#include<bits/stdc++.h>
3
+#include<vector>
4
+using namespace std;
5
+int main()
6
+{
7
+ vector<int> v;
8
+ int i,ie,n,p;
9
+ cout<<"size of array"<<endl;
10
+ cin>>n;
11
+ for(i=0;i<n;i++)
12
+ {
13
+ v.push_back(i);
14
+ }
15
16
17
+ cout<<v[i]<<" ";
18
19
+ cout<<"enter which no element you want to insert"<<endl;
20
+ cin>>ie;
21
+ cout<<"enter index where you want to enter the element"<<endl;
22
+ cin>>p;
23
+ auto it=v.begin()+p;
24
+ auto iter=v.insert(it,ie);
25
26
27
28
29
+}
0 commit comments