| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple program for putting inputs in order
I'm trying to sort 5 different numbers that a user will input into ascending order. What I got so far is using order(), but this, as far as I know, only works on pairs of two. I got it to work for 4 numbers ( 2 pairs of 2) How can I make the fifth number work? Since there isn't a sixth number to make it a pair. Unless, the fifth number is paired to some kind of null value? Putting 0 for the sixth # didnt work, because the 0 will always go to the front. Any help?
|
|
#2
|
||||
|
||||
|
Research the "Bubble Sort" algorithm. Basically, you sort items 1 and 2, then 2 and 3, then 3 and 4, then 4 and 5. Then you go back up to the top and move down one, sorting 2 and 3, 3 and 4, then 4 and 5. Then go back to the top and move down 2, sort 3 and 4, then 4 and 5. Then you're done.
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips. ![]() |
|
#3
|
|||
|
|||
|
I coudn't figure out how to use that bubble, but I did manage to use the sort(). Works pretty well. Thanks anyways.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Simple program for putting inputs in order |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|