Sorting int array with stack class

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2005
Posts: 48
Reputation: ayk-retail is an unknown quantity at this point 
Solved Threads: 0
ayk-retail ayk-retail is offline Offline
Light Poster

Sorting int array with stack class

 
0
  #1
Aug 1st, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Sorting int array with stack class

 
0
  #2
Aug 1st, 2007
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 48
Reputation: ayk-retail is an unknown quantity at this point 
Solved Threads: 0
ayk-retail ayk-retail is offline Offline
Light Poster

Re: Sorting int array with stack class

 
0
  #3
Aug 1st, 2007
Originally Posted by iamthwee View Post
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Sorting int array with stack class

 
0
  #4
Aug 1st, 2007
Are you restricted to the number of stacks you can use?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 48
Reputation: ayk-retail is an unknown quantity at this point 
Solved Threads: 0
ayk-retail ayk-retail is offline Offline
Light Poster

Re: Sorting int array with stack class

 
0
  #5
Aug 1st, 2007
Originally Posted by iamthwee View Post
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!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Sorting int array with stack class

 
0
  #6
Aug 1st, 2007
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.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC