Question: c++ Implement a linked list with a shape like the following grid. L I V E There are 4 tiles in the grid. Each tile
c++
Implement a linked list with a shape like the following grid.
| L | I |
| V | E |
There are 4 tiles in the grid. Each tile has two data members and we can define the struct like this:
struct listNode {
char data;
listNode *arr[3];
listNode (char x)
{
data = x;
arr[0] = nullptr;
arr[1] = nullptr;
arr[2] = nullptr;
};
};
Simulate the situation that a robot takes a random walk on the grid (by using a random number generator). Initially it is on the L tile. In each move it switches its position to anyone of the other three. The system displays the position that it is on. Do the random walking for 10 times and display 10 characters which the robot just stepped on.
Thank you ahead of time for your help.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
