Question: Use C++ to write a program: Consider a robot vacuum cleaner. The robot is placed in a room with tile carpeting. The robot can only
Use C++ to write a program:
Consider a robot vacuum cleaner. The robot is placed in a room with tile carpeting. The robot can only move up, down and side to side to the next tile. Your program should determine whether or not the robot will clean the entire room within a given number of moves. The moving of the robot is simulated by randomly generating a number 1, 2, 3 or 4. The number 1 represents moving up, 2 represents moving down, 3 represents moving left and 4 represents moving right. The robot must stay within the tiles of room. The robot is allowed to clean the same tile over and over again.
Input:
The input gives the initial location for the robot (row, column), the size of the room (number of tiles along the width and length of the room), and the number of moves that the robot is allowed.
Sample input: The robot is place in position (2, 3), the room size is 10 x 10 and the number of moves allowed is 200.
2 3 10 10 200
Output:
Print the floor showing which tiles were cleaned and which tiles were not cleaned. Also print a massage stating whether or not the entire room was cleaned. Let 1 represent clean and 0 represent dirty.
Sample output:
| 1
| 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 |
| 1
| 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 |
| 0
| 1 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1
| 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 0
| 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0
| 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
| 0
| 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 0
| 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0
| 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
| 0
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
The entire room was not cleaned.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
