how to make a 2d vector in c++
C++
// Create a vector containing n
//vectors of size m, all u=initialized with 0
vector<vector<int> > vec( n , vector<int> (m, 0)); // Initializing 2D vector "vect" with
// values
vector<vector<int> > vect{ { 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 } }; #include<bits/stdc++.h>
using namespace std;
int main(){
int n = 3;
int m = 4;
// Create a vector containing n
//vectors of size m.
vector<vector<int> > vec( n , vector<int> (m, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++){
cout<< vec[i][j]<< " ";
}
cout<< "\n";
}
return 0;
}
Also in C++:
- Title
- log base e synthax c++
- Category
- C++
- Title
- what does count function do in hashmap
- Category
- C++
- Title
- how to hide ui elements unity
- Category
- C++
- Title
- write to file in C++
- Category
- C++
- Title
- c++ vector pop_back
- Category
- C++
- Title
- lisy stl C++
- Category
- C++
- Title
- c++ do you not inherit constructor
- Category
- C++
- Title
- Operator overloading in C++ Programming
- Category
- C++
- Title
- input a string in c++
- Category
- C++
- Title
- centos7 mlock2
- Category
- C++
- Title
- do while loop c++
- Category
- C++
- Title
- matrix transpose tiling
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- c++ create array
- Category
- C++
- Title
- time conversion hackerrank solution in c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- c++ reading string
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- c++ ros publisher
- Category
- C++
- Title
- c++ function return array
- Category
- C++
- Title
- c++ sort
- Category
- C++
- Title
- how to declare a function in c++
- Category
- C++
- Title
- two elements with difference K in c++
- Category
- C++
- Title
- border radius layout android xml
- Category
- C++
- Title
- c++ template function
- Category
- C++
- Title
- c++ class template
- Category
- C++
- Title
- c++ stack
- Category
- C++
- Title
- erasing a character from a string in c++
- Category
- C++
- Title
- getline not working c++
- Category
- C++
- Title
- index string c++
- Category
- C++
- Title
- kruskal's algorithm c++ hackerearth
- Category
- C++
- Title
- how print fload wiht 3 decimal in c++
- Category
- C++
- Title
- sleep system function linux c++
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- std::substring
- Category
- C++
- Title
- check an stack is empty c++
- Category
- C++
- Title
- cpp how to create an object of template class
- Category
- C++
- Title
- power c++
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- ue4 c++ struct
- Category
- C++
- Title
- char to string c++
- Category
- C++
- Title
- coping 2d vector in cpp
- Category
- C++
- Title
- c++ sort vector of objects by property
- Category
- C++
- Title
- screen record ios simulator
- Category
- C++
- Title
- kruskal c++
- Category
- C++
- Title
- how to concatinate two strings in c++
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- compare string c++
- Category
- C++
- Title
- setbits
- Category
- C++
- Title
- variabvles in c++
- Category
- C++
- Title
- C++ sfinae
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- initialization list c++
- Category
- C++
- Title
- GetCurrentThreadId c
- Category
- C++
- Title
- change int to string cpp
- Category
- C++
- Title
- map arduino
- Category
- C++
- Title
- convert integer to string c++
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- c++ over load oprator to print variable of clas
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- calculate factorial
- Category
- C++
- Title
- c++ initialize array
- Category
- C++
- Title
- programa para saber si un numero es primo
- Category
- C++
- Title
- new keyword in cpp
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- check if intent has extras
- Category
- C++
- Title
- pairs in c++
- Category
- C++
- Title
- extends c++
- Category
- C++
- Title
- convert string to stream c++
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- min and max heap in cpp
- Category
- C++
- Title
- never gonna give you up lyrics
- Category
- C++
- Title
- sqrt cpp
- Category
- C++
- Title
- c++ compare char array
- Category
- C++
- Title
- restting a queue stl
- Category
- C++
- Title
- c++ modulo make it give only positive numbers
- Category
- C++
- Title
- getch c++ library
- Category
- C++
- Title
- char size length c++
- Category
- C++
- Title
- factorial in c++
- Category
- C++
- Title
- c++ while true
- Category
- C++
- Title
- 2d vector
- Category
- C++
- Title
- how to use winmain function
- Category
- C++
- Title
- c++ multidimensional vector
- Category
- C++
- Title
- root to leaf path print
- Category
- C++
- Title
- SFML window
- Category
- C++
- Title
- length of 2d array c++
- Category
- C++
- Title
- c++ delete dynamically allocated array
- Category
- C++
- Title
- c++ compare char
- Category
- C++
- Title
- never gonna give you up
- Category
- C++
- Title
- invalid types int int for array subscript c++
- Category
- C++
- Title
- c++ vector
- Category
- C++
- Title
- c++ empty stream
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- linkedlist implementation in c++
- Category
- C++
- Title
- c++ looping through a vector
- Category
- C++
- Title
- C++ If
- Category
- C++
- Title
- reference function in c++
- Category
- C++
- Title
- c++ typeid get type name
- Category
- C++
- Title
- error: redefinition of ‘class Customer’
- Category
- C++