Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem statement: and some number of disks N of different sizes. To begin, the N disks are placed on the 1st column in order of

image text in transcribed

image text in transcribed

Problem statement: and some number of disks N of different sizes. To begin, the N disks are placed on the 1st column in order of their size, with the largest disk at the bottom of the column. The puzzle's goal is to finish with the disks arranged in the same order (biggest on the bottom, smallest on the top) on the 2nd column. Of course, you can't just move the disks however you want! You need to follow these rules You can only move one disk at a time by taking it off the top of its peg and putting it onto You're not allowed to place a disk on top of another disk that's smaller-that is, every disk must be smaller than every disk beneath it on the peg Dynamically Allocated 2-D array (3 pts) Next, implement this is using a dynamically allocated 2-D array with 3 columns for the 3 posts and N rows for N disks. Get the number of disks from the user as a command-line argument, i.e. towers 5. Continue to initialize the array with the numbers corresponding to the disks in the first column and Os in all other columns to represent the initial state of the game. You should now see the above example output, given 2 for the number of disks. Remember to change your towers) and print array() function parameters to accept dynamically allocated arrays, rather than statically allocated. To help you out, your towers() function will be change to the following prototype: void towers(int number_of_disks, int *"b, int from_col, int to_col, int spare); Make sure you delete your board after calling the towers function. Create/Delete Functions for Dynamically Allocated 2-D array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions