#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int k;
cin>>k;
vector<vector<int > > v;
for(int i=0;i<k;i++)
{
vector<int> v1;
v1.push_back((int)' ');
v.push_back(v1);
}
for(int i=0;i<k;i++)
cout<<v[i][0]<<" "<<v[i][0]<<endl;
}
Mind elaborating? didn’t get your query
1 Like
If i understand you correctly, and you just want to fill spaces in an int vector, that is not possible.
however, if you want some function to return an empty 2d vector, you can simply do :
vector< vector<int> > ret_2d_vector(){
vector< vector<int> > temp;
return temp;
}
then you will also need a 2d vector to store this vector when it is returned.
but if your question was how to create an empty vector of the form arr[k][], i.e, a vector of k vectors, you can simply do :
vector< vector<int> > temp(k);
if you want to create a 2d vector of the form arr[n][m], you can do :
vector< vector<int> > temp(k, vector<int>(m));