1vector<int> myVector;
2
3myVector.push_back(1);
4myVector.push_back(2);
5myVector.push_back(3);
6myVector.push_back(4);
7
8for(auto x: myVector){
9 cout<< x << " ";
10
11}
12
13vector<pair<int,int>> myVectorOfPairs;
14
15myVectorOfPairs.push_back({1,2});
16myVectorOfPairs.push_back({3,4});
17myVectorOfPairs.push_back({5,6});
18myVectorOfPairs.push_back({7,8});
19
20for(auto x: myVectorOfPairs){
21 cout<< x.first << " " << x.second << endl;
22
23}
24
25
26
27
28
29
30
1// vector::begin/end
2#include <iostream>
3#include <vector>
4
5int main ()
6{
7 std::vector<int> myvector;
8 for (int i=1; i<=5; i++) myvector.push_back(i);
9
10 std::cout << "myvector contains:";
11 for (std::vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it)
12 std::cout << ' ' << *it;
13 std::cout << '\n';
14
15 return 0;
16}