Computer Science Canada Help finding the median number in a program |
Author: | JR [ Thu Feb 26, 2004 9:01 am ] | ||
Post subject: | Help finding the median number in a program | ||
ok, this is my program and i need to find the median(middle) of the numbers. heres my code:
|
Author: | Tony [ Thu Feb 26, 2004 2:03 pm ] | ||
Post subject: | |||
what you do is you sort your array in decending/accending order (doesn't matter... should be same answer) using something like a bubble sort for example... then just pick the number in the middle of the array by dividing it's upper limit into half.
|
Author: | nis [ Thu Feb 26, 2004 5:16 pm ] | ||||
Post subject: | |||||
to sort your list use this code
then just add the code
|
Author: | Cervantes [ Thu Feb 26, 2004 5:27 pm ] |
Post subject: | |
![]() he's already got the sorting part. It's in his post... Tony, what's a bubble sort? Is it what he has there? I haven't learned the ways of sorting in class yet, only on my own. |
Author: | JR [ Thu Feb 26, 2004 5:43 pm ] |
Post subject: | |
got it to work, thx alot |
Author: | Tony [ Thu Feb 26, 2004 8:52 pm ] |
Post subject: | |
Cervantes - yeah, that's whats posted up... you check variables with each other and if one is larger then the other, you switch them |