Arrays
Author |
Message |
shruti
|
Posted: Wed Apr 16, 2008 2:58 pm Post subject: Arrays |
|
|
i have to write a program in which i have to find the oldest & the youngest person in class but i dont know how to do that, i have tried many programs but they dont work plzzzzzzzzzzzz help me out ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Sean
![](http://compsci.ca/v3/uploads/user_avatars/47413941748406f441f83e.png)
|
Posted: Wed Apr 16, 2008 3:07 pm Post subject: RE:Arrays |
|
|
You are trying to sort them based on age. Look up Bubble Sort, it has been mentioned numerous times through the forums. |
|
|
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Wed Apr 16, 2008 3:19 pm Post subject: Re: Arrays |
|
|
Since you only need to know the oldest and the youngest, you can avoid arrays and sorting by keeping a "running" min and max. Hint: Initialize min to a high number and max to a low number. Update as you get the ages. |
|
|
|
|
![](images/spacer.gif) |
|
|