Question: I ' m writing a call function for a C + + program, please read the requirements and help me complete the following call function,
Im writing a call function for a C program, please read the requirements and help me complete the following call function, thanks:
TODO: Complete the missing blockslines in this recursive function findpath that takes the following parameters:
stage: a D array of C strings that represents the towers and floors. Each tower has at most floors, and each floor has a encounter in C string.
numtower: the number of towers.
currenttower: the current tower number counts from
numfloor: the number of floors in each tower.
exploredfloorcount: the number of floors that have been explored in the current tower.
exploredfloor: an array of integers that contains the floor numbers of the explored floors in the current tower.
strength: the current strength.
floorpath: an array of integers that you will write the best path for this tower given the floor you explored. Use it as passbyreference to return the path.
stagepath: a D array of integers that you will write the best path for this stage. Use it as passbyreference to return the best path. You may want to write it every time you finish a tower.
The function should return the highest strength that you can achieve in this stage, ie the strength after taking the best path.
int findpathint towerMAXNUMFLOOR int floorexplored int floorpath int bestfloorpath int towerindex
if towerindex MAXNUMTOWER
return ; No more towers to explore
int higheststrength ;
for int i ; i MAXNUMFLOOR; i
int recursionfloorpathMAXNUMFLOOR;
copyfloorrecursionfloorpath, floorpath;
Calculate strength for the current floor and call recursively for the next tower
int currentstrength towertowerindexi;
int recursionresult currentstrength findpathtower floorexplored, recursionfloorpath, bestfloorpath, towerindex ;
if recursionresult higheststrength
higheststrength recursionresult;
copyfloorbestfloorpath, recursionfloorpath;
bestfloorpathtowerindex i; Track the best floor for each tower
return higheststrength;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
