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?
Printable View
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?
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?
can you show how should be done, cause i dont get it
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.