944,101 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3866
  • C++ RSS
Aug 1st, 2007
0

Sorting int array with stack class

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
ayk-retail is offline Offline
48 posts
since Aug 2005
Aug 1st, 2007
0

Re: Sorting int array with stack class

Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Aug 1st, 2007
0

Re: Sorting int array with stack class

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

Thanks
Reputation Points: 10
Solved Threads: 0
Light Poster
ayk-retail is offline Offline
48 posts
since Aug 2005
Aug 1st, 2007
0

Re: Sorting int array with stack class

Are you restricted to the number of stacks you can use?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Aug 1st, 2007
0

Re: Sorting int array with stack class

Click to Expand / Collapse  Quote originally posted by iamthwee ...
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!
Reputation Points: 10
Solved Threads: 0
Light Poster
ayk-retail is offline Offline
48 posts
since Aug 2005
Aug 1st, 2007
0

Re: Sorting int array with stack class

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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Needed some help
Next Thread in C++ Forum Timeline: More sorting problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC