Search
 
SCRIPT & CODE EXAMPLE
 

CPP

input 2d vector c++

vector<vector<int> > d;
int val;
for(int i = 0; i < in; i++){
    vector<int> temp;
    for(int j = 0; j < in; j++){
        cin >> val;
        temp.push_back(val);
    }
    d.push_back(temp);
    temp.clear();
}
From SpyrosD3v25
Comment

input 2d vector c++

vector<vector<int> > d;
int val;
for(int i = 0; i < in; i++){
    vector<int> temp;
    for(int j = 0; j < in; j++){
        cin >> val;
        temp.push_back(val);
    }
    d.push_back(temp);
    temp.clear();
}
Comment

how to take input in 2d vector in c++

std::vector<vector<int>> d;
//std::vector<int> d;
cout<<"Enter the N number of ship and port:"<<endl;
cin>>in;
cout<<"Enter preference etc..:
";
for(i=0; i<in; i++){ 
cout<<"ship"<<i+1<<":"<<' ';
    for(j=0; j<in; j++){
    cin>>temp;
    d[i].push_back(temp); 
    }
}
Comment

how to take input in 2d vector in c++

std::vector<vector<int>> d;
//std::vector<int> d;
cout<<"Enter the N number of ship and port:"<<endl;
cin>>in;
cout<<"Enter preference etc..:
";
for(i=0; i<in; i++){ 
cout<<"ship"<<i+1<<":"<<' ';
    for(j=0; j<in; j++){
    cin>>temp;
    d.push_back(temp);// I don't know how to push_back here!!
    }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: phi function (n log (log(n))) 
Cpp :: fractional knapsack problem 
Cpp :: tr bash 
Cpp :: C++ Vector Operation Change Elements 
Cpp :: c++ power of two 
Cpp :: c++ unordered_map initialize new value 
Cpp :: c++ initialize size of 3d vector 
Cpp :: C++ Class Template Declaration 
Cpp :: replace a char in string c++ at a specific index 
Cpp :: unordered_map in c++ 
Cpp :: conversion of class type data into basic type data in c++ 
Cpp :: logisch oder 
Cpp :: C++ ss 
Cpp :: print numbers after decimal point c++ 
Cpp :: store arbitrarly large vector of doubles c++ 
Cpp :: two dimensional array A[N,M] with the random numbers from 10 to 90. 
Cpp :: c++ round number to 2 decimal places 
Cpp :: whatsup 
Cpp :: cap phat dong mang 2 chieu trong c++ 
Cpp :: c++ stack 
Cpp :: decemal representation 
Cpp :: reading matrix from text file in c++ and adding them and then storing them in oother c++ file 
Cpp :: ordine crescente di numeri indefiniti in c++ 
Cpp :: c++ to c code converter 
Cpp :: stack algorithm in c++ 
Cpp :: Catcoder mars rover solution in c++ 
Cpp :: servicenow cart api 
Cpp :: converting a string to lowercase inbuld function in cpp 
Cpp :: default argument c++ 
Cpp :: c++ string to vector using delimiter 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =