Question about a simple sorting method without arrays
Expand Post »
The requirements are actually simple, just asking to sort a few, say 10, 20 or so, intergers in ascending order. However, array and pointers are not allowed to be used, and just the fundamental knowledge about flow control are permitted. The hints are as follows:
1. Initialize a variable F that keeps a very large number (larger than any number in the to-be -sorted batch)
2. Search among the batch for the biggest number, which is smaller F
3. Show that number on the screen
4. Save that number to F and take away the number from the batch
5. Repeat steps 2,3 and 4 until all the 5 numbers in the batch are shown on the screen
you can access them by memory addresses... so the integers should be given addresses that are consecutive. could count as pointing really.
Thank you any way, but you didn't see the question carefully, arrays and pointers are not
allowed to be used, only the fundamental knowledge of the flow control are permited and
that's why the hints, the initialization of the large number F are for.
Re: Question about a simple sorting method without arrays
This website doesn't provide source code, and I understand that, however, is there anybody who manages this website can come up with some useful ideas. I'm only a
new learner of C++, and what I'm asking is
only some fundamental thing.
This website doesn't provide source code, and I understand that, however, is there anybody who manages this website can come up with some useful ideas. I'm only a
new learner of C++, and what I'm asking is
only some fundamental thing.
According to the sorting algorithm I have already told you its the Selection sorting.
But i don't think so you can possibly create the batch of no without using array or pointer.
Other crazy solutions might be using link list or objects or blah blah blah.. for just a simple sorting.
Last edited by Rhohitman; Oct 10th, 2008 at 1:35 pm.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.