Question: C++11 3. (5 points) Write a function n2top that receives and passes back an STL stack of integers, a stack, and receives an integer n.

C++11

C++11 3. (5 points) Write a function n2top that receives and passes

3. (5 points) Write a function n2top that receives and passes back an STL stack of integers, a stack, and receives an integer n. This function moves the nh element (counting from the top, which is element 1) of the stack to the top of the stack. For example, if an integer stack s has the elements: (top) 3 4 17 5 8, then after the call n2top (s, 4), the stack will have elements: (top) 5 3 4 178. You may use only additional (local) stack(s) and individual variables to solve this problem. (L.e., use other data structures is not allowed.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!