Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming: //-------------------------------------------------- // Problem #24 // Problem24.c //-------------------------------------------------- #include #include #include #define SHOWCLIMB const int LARGEST_STEPSIZE = 2; //-------------------------------------------------- int main() //-------------------------------------------------- { void

C Programming:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

//--------------------------------------------------

// Problem #24

// Problem24.c

//--------------------------------------------------

#include

#include

#include

#define SHOWCLIMB

const int LARGEST_STEPSIZE = 2;

//--------------------------------------------------

int main()

//--------------------------------------------------

{

void ClimbNStairs(int climb[],int steps,const int n,int *ways);

int n;

printf("n? ");

while ( scanf("%d",&n) != EOF )

{

int *climb = (int *) malloc(sizeof(int)*(n+1));

int ways;

ways = 0;

ClimbNStairs(climb,0,n,&ways);

#ifndef SHOWCLIMB

printf("%10d ways ",ways);

#endif

free(climb);

printf("n? ");

}

system("PAUSE");

return( 0 );

}

//--------------------------------------------------

void ClimbNStairs(int climb[],int steps,const int n,int *ways)

//--------------------------------------------------

{

int LengthOfClimb(const int climb[],const int steps);

if ( LengthOfClimb(climb,steps) == n )

{

(*ways)++;

#ifdef SHOWCLIMB

{

Student provides missing code to display the climb[] using the required format.

}

#endif

}

else

{

int stepSize;

Student provides missing code to consider adding/deleting a 1-stair step to climb,

then adding/deleting a 2-stair step to climb[],..., finally, adding/deleting a

LARGEST_STEPSIZE-stair step to climb[]. You must "sandwich" a recursive call between each

add and delete. Hints Consider the state-space tree that describes the solution space

for this problem. It is only possible to make a stepSize-stair step

when (LengthOfClimb(climb,steps)+stepSize

}

}

//--------------------------------------------------

int LengthOfClimb(const int climb[],const int steps)

//--------------------------------------------------

{

Student provides missing code to compute the quantification

steps

climb[i]

i = 1

}

PLEASE fill in the missing source code in the THREE designated areas in the source file Problem24.c (located below) that says "Student provides missing code..." below. Please also provide a screenshot(s) of the compiled output once complete. I have provided sample ones which should give an idea on how it should look

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

Question

5. Hedging. What is a hedge?

Answered: 1 week ago