|
-
Jan 7th, 2012, 08:12 AM
#1
Thread Starter
Fanatic Member
Display numbers
How to make a program that to display the numbers from biggest to small number
I write 3 numbers for example: 2, 6, 1
This are the numbers that i will write
and to display them in this type from biggest to smallest : 6, 2, 1
How to do it?
-
Jan 7th, 2012, 04:49 PM
#2
Re: Display numbers
You would preferably store the values in an array and sort it using the sorting algorithm of your choice. There are lots of sorting algorithms to choose from. Most beginners would implement bubble sorting, which is a terribly inefficient algorithm but for small sets of data in an application that is not performance-critical it is sufficient.
If you are interested in performance, look into quicksort.
I believe the standard template library includes an implementation of quicksort, but I take it you are looking to implement the algorithm yourself?
-
Jan 8th, 2012, 04:06 AM
#3
Thread Starter
Fanatic Member
Re: Display numbers
can you show how should be done, cause i dont get it
-
Jan 8th, 2012, 12:20 PM
#4
Re: Display numbers
What is it that you don't get?
Have you looked at the std::sort function? Include the algorithm header and you'll find it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|