954,224 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sorting int array with stack class

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!

ayk-retail
Light Poster
48 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
http://www.combinatorics.org/Volume_9/PDF/v9i2a1.pdf


I am sorry, but I am a newbie regarding C++, is there a more simple method to solving this dilemma?

Thanks

ayk-retail
Light Poster
48 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
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!

ayk-retail
Light Poster
48 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You