I am trying to figure out how to sort an array with a stack class. The array (pointer) and its length should be passed to the function as parameters so that the original will be sorted. The array created in main() should contain a maximum of 20 integers which should be entered at runtime (input to be ended by the value 0 or automatically when the 20th value is entered). As it it is going through the array, it should place the largest number onto the stack (push). Each time it steps through the array it should find the next smallest number and push it onto the stack. I can assume no two numbers are duplicated in the array. When the stack is popped, all entries should appear in ascending order.

Thank you so much!

Recommended Answers

All 5 Replies

Member Avatar for iamthwee

Are you restricted to the number of stacks you can use?

Are you restricted to the number of stacks you can use?

No, but I would like to limit it to the minimum possible.

Thanks so much again!

Member Avatar for iamthwee

Well then if you are not restricted by the number or the specific configuration ( serial or parallel ) of the stacks, a simple solution exists.

Am I going to show you? No that is your job.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.