-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectorSTL.cpp
More file actions
29 lines (22 loc) · 739 Bytes
/
vectorSTL.cpp
File metadata and controls
29 lines (22 loc) · 739 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
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> numbers;
numbers.push_back(0);
for(int i = 1; i <= 10; i++){
numbers.push_back(i);
}
/* for (auto it = numbers.begin(); it!=numbers.end(); it++){
// cout << it << endl;
cout << *it << endl; // value of the element
cout << &it << endl; // address of the iteerator
cout << &(*it) << endl; // address of the element
} */
numbers.insert(numbers.begin() + 5, 88); // insert 88 at position 5
numbers.erase(numbers.begin() + 5); // remove element at position 5
numbers.pop_back(); // remove element at the back of the vector
for (auto n : numbers)
cout << n << endl;
}