Vector 2D

Run Settings
LanguageC++
Language Version
Run Command
//LEARN VECTOR //https://www.geeksforgeeks.org/2d-vector-in-cpp-with-user-defined-size/ #include <iostream> #include <vector> // for 2D vector using namespace std; int main() { // Initializing 2D vector "vect" with // values vector<vector<int> > vect{ { 1, 2 }, { 4, 5, 6 }, { 7, 8, 9 } }; // Displaying the 2D vector for (int i = 0; i < vect.size(); i++) { for (int j = 0; j < vect[i].size(); j++) { cout << vect[i][j] << " "; //cout << "vect.size(): " << vect.size() << endl; //num of rows //cout << "vect[i].size(): " << vect[i].size() << endl; //num of column } cout << endl; } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines