Question: C++ programming question: The below code creates a grid based on user input, I need to spawn two characters ( one in the upper right

C++ programming question: The below code creates a grid based on user input, I need to spawn two characters ( one in the upper right hand corner and one in the lower left hand corner denoted with a * on the grid). Every second the characters will move one random direction ( north, south, east or west). Once they end up on the same array position the problem will end displaying how many moves it took. I am having trouble figuring out what to do next. Please help if you can.

#include

int main()

{

unsigned int rows = 0, cols = 0;

std::cout << "Enter 2 <= Rows <=50: ";

std::cin >> rows;

std::cout << "Enter 2 <= Columns <=50: ";

std::cin >> cols;

while (! (rows >=2 && rows <= 50 && cols >=2 && cols <= 50 && rows != cols))

{

std::cout << "Invalid Input ";

std::cout << "Enter 2 <= Rows <=50: ";

std::cin >> rows;

std::cout << "Enter 2 <= Columns <=50: ";

std::cin >> cols;

}

int arrayxy [rows][cols];

for (int i = 0; i < rows; ++i)

{

for(int j = 0; j < cols; ++j)

{

arrayxy[i][j] = 0;

std::cout << arrayxy[i][j];

}

std::cout << ' ';

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!