Thread: Re: [Dev-C++] Function to order elements
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alfred P. R. <al...@ya...> - 2005-04-25 04:09:37
|
Hi Alexsandro, If you place the numbers into a list then they will sort with the sort member function. #include <list> ... std::list <int> a_list; ... a_list.push_back(integer_number); ... a_list.sort(); Vector also has this capability. You may have to create a predicate function if you are tring to sort on an element of a structure that is in the list delcaration. The links go to the MSDN pages for the given members. Hopefully that helps somewhat! Alexsandro Meireles <mei...@gm...> wrote: Hi, all! Does anyone know any function to order elements? What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 545 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from the minimum value to the maximum value. Thanks in advance! -- Alexsandro Meireles Alfred P. Reaud |
|
From: <Mat...@Ve...> - 2005-04-26 15:31:55
|
I think for a beginner maybe it's a priority that he understand the algorithm? -----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of Per Westermark Sent: Tuesday, April 26, 2005 12:09 AM To: Daniel Pettersson Cc: Alexsandro Meireles; Dev C++ Subject: Re: [Dev-C++] Function to order elements No need to ever try bubble-sort except for real desperation in an embedded system where code space is a premium. There are so many better sort methods immediately available - several of them already existing in the normal C/C++ libraries... /Per W On Mon, 25 Apr 2005, Daniel Pettersson wrote: > use bubblesort > > http://www.devx.com/vb2themax/Tip/18972 > > it works perfect for smaller arrays > > > Alexsandro Meireles wrote: > > > Hi, all! > > > > Does anyone know any function to order elements? > > > > What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 > > 545 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from > > the minimum value to the maximum value. > > > > Thanks in advance! > > > > -- > > Alexsandro Meireles > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users ___________________________________________________________________ The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. |
|
From: Per W. <pw...@ia...> - 2005-04-26 16:23:50
|
Not many people know how malloc() works, or how sqrt() is evaluated... qsort() from the C library is (almost) always available and is quite good. C++ also have good sort methods immediately available. I think it is preferable to separate knowledge of algorithms (quick-sort, bubble-sort, heap-sort, ...) from knowledge about a language. /Per W On Tue, 26 Apr 2005 Mat...@Ve... wrote: > I think for a beginner maybe it's a priority that he understand the > algorithm? > > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of Per > Westermark > Sent: Tuesday, April 26, 2005 12:09 AM > To: Daniel Pettersson > Cc: Alexsandro Meireles; Dev C++ > Subject: Re: [Dev-C++] Function to order elements > > > No need to ever try bubble-sort except for real desperation in an embedded > system where code space is a premium. There are so many better sort > methods immediately available - several of them already existing in the > normal C/C++ libraries... > > /Per W > > On Mon, 25 Apr 2005, Daniel Pettersson wrote: > > > use bubblesort > > > > http://www.devx.com/vb2themax/Tip/18972 > > > > it works perfect for smaller arrays > > > > > > Alexsandro Meireles wrote: > > > > > Hi, all! > > > > > > Does anyone know any function to order elements? > > > > > > What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 > > > 545 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from > > > the minimum value to the maximum value. > > > > > > Thanks in advance! > > > > > > -- > > > Alexsandro Meireles > > > > > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > ___________________________________________________________________ > The information contained in this message and any attachment may be > proprietary, confidential, and privileged or subject to the work > product doctrine and thus protected from disclosure. If the reader > of this message is not the intended recipient, or an employee or > agent responsible for delivering this message to the intended > recipient, you are hereby notified that any dissemination, > distribution or copying of this communication is strictly prohibited. > If you have received this communication in error, please notify me > immediately by replying to this message and deleting it and all > copies and backups thereof. Thank you. > |
|
From: <Mat...@Ve...> - 2005-04-26 16:25:42
|
I do agree but my point would be in this case, that the knowledge of language and of algorithm would appear to coincide? -----Original Message----- From: Per Westermark [mailto:pw...@ia...] Sent: Tuesday, April 26, 2005 9:23 AM To: Mat...@Ve... Cc: dan...@st...; mei...@gm...; dev...@li... Subject: RE: [Dev-C++] Function to order elements Not many people know how malloc() works, or how sqrt() is evaluated... qsort() from the C library is (almost) always available and is quite good. C++ also have good sort methods immediately available. I think it is preferable to separate knowledge of algorithms (quick-sort, bubble-sort, heap-sort, ...) from knowledge about a language. /Per W On Tue, 26 Apr 2005 Mat...@Ve... wrote: > I think for a beginner maybe it's a priority that he understand the > algorithm? > > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of Per > Westermark > Sent: Tuesday, April 26, 2005 12:09 AM > To: Daniel Pettersson > Cc: Alexsandro Meireles; Dev C++ > Subject: Re: [Dev-C++] Function to order elements > > > No need to ever try bubble-sort except for real desperation in an embedded > system where code space is a premium. There are so many better sort > methods immediately available - several of them already existing in the > normal C/C++ libraries... > > /Per W > > On Mon, 25 Apr 2005, Daniel Pettersson wrote: > > > use bubblesort > > > > http://www.devx.com/vb2themax/Tip/18972 > > > > it works perfect for smaller arrays > > > > > > Alexsandro Meireles wrote: > > > > > Hi, all! > > > > > > Does anyone know any function to order elements? > > > > > > What I need is to pick up a list of numbers like: 1 232 44 5 5 45 5 45 > > > 545 and get an ordered list like 1 5 5 5 44 45 45 232 545, i.e., from > > > the minimum value to the maximum value. > > > > > > Thanks in advance! > > > > > > -- > > > Alexsandro Meireles > > > > > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > ___________________________________________________________________ > The information contained in this message and any attachment may be > proprietary, confidential, and privileged or subject to the work > product doctrine and thus protected from disclosure. If the reader > of this message is not the intended recipient, or an employee or > agent responsible for delivering this message to the intended > recipient, you are hereby notified that any dissemination, > distribution or copying of this communication is strictly prohibited. > If you have received this communication in error, please notify me > immediately by replying to this message and deleting it and all > copies and backups thereof. Thank you. > |