Question
C Programming: //-------------------------------------------------- // Problem #24 // Problem24.c //-------------------------------------------------- #include #include #include #define SHOWCLIMB const int LARGEST_STEPSIZE = 2; //-------------------------------------------------- int main() //-------------------------------------------------- { void
C Programming:
//--------------------------------------------------
// 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 lookStep 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