I am working on C++ printing vectors in grid. Here, I need to put random numbers in a vector size of 3x * 3y. And then I have to print them out with two dimensional matrix with one array. I do not understand how to represent two dimensional matrix with one array. In addition, I am not sure how to print out multidimensional vectors. I have to work on print_vector function which prints vectors with grid form. Could you please help me to improve this code below?
int main()
{
populate_vector();
return 0;
}
void populate_vector()
{
int x,y;
cout<<"Enter two Vectors x and y \n->";
cin>> x;
cin>> y;
srand((unsigned)time(NULL));
std::vector<int> xVector((3*x) * (3*y));
for(int i = 0; (i == 3*x && i == 3*y); ++i){
xVector[i] = rand() % 255 + 1;
if(i == 3*x){
cout << "\n";
}
}
print_vector(xVector);
}
void print_vector(vector<int> &x) {
}