arranging 5 numbers from lowest to highest PLS HELP

Reply

Join Date: Jul 2009
Posts: 10
Reputation: stevenaseron is an unknown quantity at this point 
Solved Threads: 0
stevenaseron stevenaseron is offline Offline
Newbie Poster

arranging 5 numbers from lowest to highest PLS HELP

 
0
  #1
Jul 6th, 2009
um ive been asked by my prof to do a program that could possibly arrange 5numbers from lowest to highest..but im kinda new with programing can sumone pls help me THNXX
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 7
Reputation: trshaaa is an unknown quantity at this point 
Solved Threads: 2
trshaaa trshaaa is offline Offline
Newbie Poster

Re: arranging 5 numbers from lowest to highest PLS HELP

 
0
  #2
Jul 6th, 2009
I which language...?I can pots you one solution in c if you want....
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 10
Reputation: stevenaseron is an unknown quantity at this point 
Solved Threads: 0
stevenaseron stevenaseron is offline Offline
Newbie Poster

Re: arranging 5 numbers from lowest to highest PLS HELP

 
0
  #3
Jul 6th, 2009
jbasic...thnxx
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: arranging 5 numbers from lowest to highest PLS HELP

 
0
  #4
Jul 6th, 2009
There are many sort algorithms in existance. The simplest but slowest is you have all your values in an array and you know the count of the array.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2.  
  3. swap = true
  4. while swap is true
  5. swap = false
  6. for index = 0 to cnt-1 step 1
  7. if ary[index] > ary[index+1] then
  8. tmp = ary[index]
  9. ary[index]=ary[index+1]
  10. ary[index+1] = ary[index]
  11. swap = true
  12. endif
  13. endfor
  14. endwhile

This one is very inefficient but will do the job. In essence the outer loop will loop forever until no swaps occur in the inner loop. This is know as a bubble sort as the numbers bubble along into their correct positions.

I strongly recommend you read up on sorting. Knuth has a great book on the subject containg pseudo code. His books are well worth having a prominent place in your bookcase.


Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. [45][ 3][21][11][2]
  2. 3 45 21 11 2
  3. 3 21 45 11 2
  4. 3 21 11 45 2
  5. 3 21 11 45 2
  6. next outer loop without the little steps
  7. 3 11 21 2 45
  8. 3 11 2 21 45
  9. 3 2 11 21 45
  10. 2 3 11 21 45
Last edited by wildgoose; Jul 6th, 2009 at 11:23 am. Reason: adjustment
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 10
Reputation: stevenaseron is an unknown quantity at this point 
Solved Threads: 0
stevenaseron stevenaseron is offline Offline
Newbie Poster

Re: arranging 5 numbers from lowest to highest PLS HELP

 
0
  #5
Jul 6th, 2009
o ok..ow and thnxx alot i really needed these codes
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 10
Reputation: stevenaseron is an unknown quantity at this point 
Solved Threads: 0
stevenaseron stevenaseron is offline Offline
Newbie Poster

Re: arranging 5 numbers from lowest to highest PLS HELP

 
0
  #6
Jul 6th, 2009
dude can u help me do this in a flowchart ? cuz im told to do it that way PLS HELP ME this really means alot to me THNXX
Last edited by stevenaseron; Jul 6th, 2009 at 11:42 am.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC