1#include <iostream>
2#include <vector>
3
4#define M 3
5#define N 4
6
7int main()
8{
9 // specify default value to fill the vector elements
10 int default_value = 1;
11 // first initialize a vector of ints with given default value
12 std::vector<int> v(N, default_value);
13 // Use above vector to initialize the two-dimensional vector
14 std::vector<std::vector<int>> matrix(M, v);
15
16 return 0;
17}
18
1// Initializing 2D vector "vect" with
2// values
3vector<vector<int> > vect{ { 1, 2, 3 },
4 { 4, 5, 6 },
5 { 7, 8, 9 } };
1#include <bits/stdc++.h>
2#include <vector>
3using namespace std;
4
5int main()
6{
7// This vector initializes with the values: 10, 20, and 30
8 vector<int> vect{ 10, 20, 30 };
9
10 return 0;
11}
1vector<int> a; // empty vector of ints
2vector<int> b (5, 10); // five ints with value 10
3vector<int> c (b.begin(),b.end()); // iterating through second
4vector<int> d (c); // copy of c