Search
 
SCRIPT & CODE EXAMPLE
 

CPP

2dvector c++

 	int n = 3;
    int m = 4;
 
    /*
    We create a 2D vector containing "n"
    elements each having the value "vector<int> (m, 0)".
    "vector<int> (m, 0)" means a vector having "m"
    elements each of value "0".
    Here these elements are vectors.
    */
    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<< endl;
    }
     
Comment

2dvector c++

 	int n = 3;
    int m = 4;
 
    /*
    We create a 2D vector containing "n"
    elements each having the value "vector<int> (m, 0)".
    "vector<int> (m, 0)" means a vector having "m"
    elements each of value "0".
    Here these elements are vectors.
    */
    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<< endl;
    }
     
Comment

PREVIOUS NEXT
Code Example
Cpp :: The elements are store at contiguous memory locations in C++ 
Cpp :: Consider a pair of integers, (a,b). The following operations can be performed on (a,b) in any order, zero or more times: - (a,b) - ( a+b, b ) - (a,b) - ( a, a+b ) 
Cpp :: how to srt vector array 
Cpp :: c++ else 
Cpp :: C++ initializing a thread with a class/object with parameters 
Cpp :: void does not a name a type in cpp 
Cpp :: c++ cin accept only numbers 
Cpp :: compile c++ MPI Program 
Cpp :: bullet physics directx 11 
Cpp :: c++ ascii value 
Cpp :: c++ max and min of vector 
Cpp :: c++ & operator 
Cpp :: c++ set element at index 
Cpp :: program to find third smallest number c++ 
Cpp :: c++ define constant 
Cpp :: how to make an enum in c++ 
Cpp :: cpp set time 
Cpp :: Dfs program in c++ 
C :: docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. 
C :: how to download file in powershell 
C :: find maximum number between 3 numbers in c 
C :: remove on condtion in vec rust 
C :: c loop through binary search tree 
C :: Successeur récurssive 
C :: c concatenate strings 
C :: c Program to check if a given year is leap year 
C :: to find greatest of 4 numbers in c 
C :: sum average min max in c array 
C :: go Iterating over an array using a range operator 
C :: count distinct characters in a string C 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =