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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started